javascript - Pass in parameter to a react component when rendered from a method -


i playing react.js (i new it) , had strange issue.

i can render sub-component parent's render. works:

<station id="1" label="start" /> 

i tried extract method:

renderstation(id, label) {   return <station id="{id}" label="{label}" /> } // call render() {this.renderstation(1, "start")} 

strangely passes in strings "{id}" , "{label}" props instead of "1" , "start". rendering <div>{id}</div> same method works fine. wrong?

see playground repro here: https://jscomplete.com/repl?j=hybekzuub

please remove double quotes, , go.

<station id={id} label={label} />


Comments

Popular posts from this blog

python - Operations inside variables -

Generic Map Parameter java -

arrays - What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it? -