Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Render not called when dispatch #87

Closed
K4stor opened this issue Sep 2, 2015 · 5 comments
Closed

Render not called when dispatch #87

K4stor opened this issue Sep 2, 2015 · 5 comments

Comments

@K4stor
Copy link

K4stor commented Sep 2, 2015

Hello

I am trying to port my project to Redux.
My components are react already. And I added
everything needed (or at least I think so) to
obey the redux framework.

But my React Component wont re-render even if I use
export default connect(state => state)(WorkspaceView)

The reducer gets called, the state is altred, but nothing happens.
When I force a render manually it works.

I uploaded my project here https://dl.dropboxusercontent.com/u/11300320/PTG.zip , and the component I am writing about is called Workspace view.
Just dload it, run npm install gulp and ./run.
It uses electron.io therefore the run command
Please help me !

Regards Carsten

@alanrubin
Copy link

Hi @K4stor I have looked into your code, it seems you are mutating your state in your reducer, you are pushing a new entry into operations array instead of creating a new array. See http://rackt.github.io/redux/docs/basics/Reducers.html or http://rackt.github.io/redux/docs/Troubleshooting.html in the first section. Your state needs to be immutable so that re-render is triggered. Hope it helps !

@K4stor
Copy link
Author

K4stor commented Sep 2, 2015

Ah ok that makes sense. Thank you very much ! I will try it tomorrow and let you know if it worked

@gaearon
Copy link
Contributor

gaearon commented Sep 2, 2015

@gaearon gaearon closed this as completed Sep 2, 2015
@bdavisx
Copy link

bdavisx commented Mar 23, 2016

Just wanted to update the link that Dan posted above, the troubleshooting section has moved and this shows up pretty high in searches:

https://github.com/reactjs/react-redux/blob/master/docs/troubleshooting.md#my-views-arent-updating

@markerikson
Copy link
Contributor

Yeah, mutating state is the reason for components not updating like 98% of the time. I've written up an answer on this in my FAQ. It's not merged in yet, so I'll link to the WIP branch: https://github.com/markerikson/redux/blob/merge-faq-page/docs/FAQ.md#why-isnt-my-component-re-rendering-or-my-mapstatetoprops-running

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants