Answer the question
In order to leave comments, you need to log in
How to assign a react component to a link?
This is how it doesn't work -
store_changeHandler = (event)=>{
var Component = this.props.store.view;
this.setState({
component: <Component />
});
};
render() {
return <div>{this.state.component}</div>;
}
store_changeHandler = (event)=>{
this.setState({
component: this.props.store.view
});
};
render() {
var Component = this.state.component;
return <div>{<Component />}</div>;
}
Answer the question
In order to leave comments, you need to log in
This is how it will work:
store_changeHandler (event) {
var Component = this.props.store.view;
this.setState({
component: (<Component />)
});
};
render() {
return <div>{this.state.component}</div>;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question