question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Actions not passed to connected component on server.

See original GitHub issue

I 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:closed
  • Created 5 years ago
  • Comments:13 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
christianalfonicommented, Jan 23, 2020

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:

const onInitialize = ({ actions }) => actions.isomorphicOnInitialize()

Now you can call this action manually when on the server 😃

Or just manually call it on the client as well:

const overmind = createOvermind(config)
overmind.actions.isomorphicOnInitialize()

I will write about it in the docs 😃

1reaction
suevalovcommented, Dec 3, 2019

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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found