Can I store my stateful jsx in the redux store?
I ran into a situation like this, I have a local computed state, and I have a component using that state. And I want to use the same computed state component in a different route. Using the same computation code on a different route didn't make sense in the template, so I instead passed my component with local state to that route.
It works like this:
let myJsx = (customState)=><Component customState={customState} />
navigateToRoute(someData, myJsx){
this.props.actions.updateReduxStore(myJsx);
.. do something with someData.
.. browswerHistory('navigatetoPage');
}
render(){
return (
..
.
<a onClick={() => {
let myJsx = myJsx(params);
this.navigateToRoute(someData, myJsx)
}}
/>
.
..
);}
So, I am deliberately pushing my jsx to the redux store, which is rare, but possible, but are there certain risks for this. Is this good practice?
+3
source to share
No one has answered this question yet
Check out similar questions: