Jessie Anderson
Jessie Anderson

Reputation: 319

pass dynamic props in jxs using string literal

I know we can setState or get state on dynamic variables

like this.state[`id-$(id)`] or this.state[someVariable] but can we pass dynamic props down to children component?

<div what_to_do_here={this.state[`id-${id}`]} />hello</div>

Upvotes: 0

Views: 161

Answers (1)

monssef
monssef

Reputation: 1004

one way to do it is by using an object to gather your props + the spread operator (ES2015).

  render() {
    const myProps = { a: 4, f: 1 };
    return <Application {...myProps} />;
  }

Upvotes: 1

Related Questions