Actions not passed to connected component on server.
See original GitHub issueI am not sure if this is done by design, but having the app setup as instructed in the structuring your app
and server rendering
sections of the guide my app on the server breaks. I am getting and error cannot real modals of undefined error when trying to access actions.modals.openModal
in an onClick handler.
const { actions } = useOvermind(); In render
return (
<div onClick={actions.sidebars.toggleDrawer}></div>
)
I could set actions to a default {} but wanted to make sure I wasn’t doing anything wrong.
Huge fan of this library coming from Baobab and Celebral! Great Work!
Issue Analytics
- State:
- Created 5 years ago
- Comments:13 (8 by maintainers)
Top Results From Across the Web
How to call actions without using @connect? #362 - GitHub
I have a header container which passes image data (url, size) down to a header component using @connect(state => ({ header: state.header }))...
Read more >Actions passed as props in Redux connected component are ...
The raw component is not Redux-aware, it just gets props from the Redux store and use them. As the testing needs to be...
Read more >How passing props to component works in React
Master how to pass props (properties) to components in React with this useful beginner's guide, including demo code.
Read more >5 Ways to Connect Redux Actions - Bene Studio
From connect's docs: mapDispatchToProps […] If an object is passed, each function inside it is assumed to be a Redux action creator. An...
Read more >Troubleshooting | Redux
Sometimes, you are trying to dispatch an action, but your view does not update. Why does this happen? There may be several reasons...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Ah, yeah, no it does not fire up. The reason is that it is considered a side effect on the server that you might not want. Like with tests, you do not want onInitialize to fire up as it would cause a side effect to your tests.
But what I suggest you do here is to rather create your own action an do:
Now you can call this action manually when on the server 😃
Or just manually call it on the client as well:
I will write about it in the docs 😃
Hi @christianalfoni! I’ve stumbled upon with this limitation as well and I don’t see any reasons why the actions should not be available in SSR version.
Basically we should be able to render the application on a server and hydrate all mutations at the end of the render without any limitations.
Something like this: https://github.com/zeit/next.js/tree/canary/examples/with-mobx-state-tree-typescript