javascript - React-Native variable as component name -


i'm trying build app react-native. have multiple classes , want display class depending on state.

let mycomponent = this.props.navigationstate.routes[this.props.navigationstate.index].component; 

this gives me string 'scene1' (witch name of component)

after want display component this

return <mycomponent />; 

i'm getting error:

expected component class, got [object object].

if display component this:

return <scene1 />; 

it displays component.

does know whats difference between these 2 examples? can't understand why variable containing string not same string. maybe i'm missing small detail don't know whats wrong here

edit: requested route

class scene1 extends component {      render() {          return(             <view style={{flex: 1, justifycontent: 'center', alignitems: 'center', backgroundcolor: 'yellow'}}>                 <text>scene1</text>                 <view>                     <text onpress={ () => this.props.navigate({ type: 'push', key: 'scene2' })}>go scene2</text>                 </view>             </view>         );     }  } 

i found same thing, i'm not sure rules jsx parser applying. can tell works:

<this.props.componentclass /> 

Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -