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.

Render not called when dispatch

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

9reactions
alanrubincommented, Sep 2, 2015

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 !

0reactions
markeriksoncommented, Mar 25, 2016

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Does render called or updated after dispatch and set state
You are trying to render the members list based on the state of the component when the actualy data is coming through props...
Read more >
Hooks | React Redux
When the function component renders, the provided selector function will be called and its result will be returned from the useSelector() hook. (A...
Read more >
When does React render your component? - Zhenghao
Your components – functions augmented by React with the ability to schedule an update on the UI – are called by React, not...
Read more >
How and when to force a React component to re-render
React automatically re-renders components, but what happens when a component is not updating as expected? Find out what you can do here.
Read more >
Connect: Dispatching Actions with mapDispatchToProps
This is a common error that happens when you try to call this.props.dispatch , but dispatch is not injected to your component. dispatch...
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