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.

React-Redux 6 doesn't trigger state/changes after upgrading

See original GitHub issue

Do you want to request a feature or report a bug?

Probably a bug or conflicts with other packages.

What is the current behavior?

I have been using react-redux 5.1.1, after upgrading to v6.0.0 my components stopped getting any updates from store, events are dispatched, state is updated, but no changes are being propagated to components, therefore nothing is rendered.

Here is a video for better understanding the problem - https://www.screencast.com/t/NE5wouflLs

What is the expected behavior?

Should work without changing anything as far as no braking changes were introduced.

Which versions of React, ReactDOM/React Native, Redux, and React Redux are you using? Which browser and OS are affected by this issue? Did this work in previous versions of React Redux?

package.json file that works - https://gist.github.com/CROSP/f89558dee71f3dcf4bfbecec71e9d248 package.json file that causes such weird behavior - https://gist.github.com/CROSP/f251b7596da98658a624742b55116c5e

Did anyone face similar issues?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
markeriksoncommented, Dec 31, 2018

FWIW, I pasted the app.js file into Expo Snack and it worked fine there toggling between v5 and v6. I’ve never worked with RN before, so I’m not sure what tooling I would need to try out the repo locally.

1reaction
grvkcommented, Dec 30, 2018

Hello guys,

I spent a couple days dealing with issue. It got resolved when I rolled back to redux-react version 5. I also put together a sample project that shows this issue (I tested it on iOS simulator only. Not sure about Android):

import React, { Component } from 'react';
import { createStore, combineReducers } from 'redux';
import { Provider, connect } from "react-redux";
import { Text } from 'react-native';

// ACTIONS
const getHomePageTextbooks = () => {
  return {
    type: 'GET_DATA'
  };
};

// REDUCER
const INITIAL_STATE = {
  data: []
};

const HomePageTextbooks = (previousState = INITIAL_STATE, action) => {
  switch (action.type) {
    case 'GET_DATA':
      return { data: [1,2,3,4,5,6,7] };
    default:
      return previousState;
  }
};

// STORE
const store = createStore(HomePageTextbooks);
setTimeout(() => { console.log("LAST STORE'S STATE: ", store.getState())}, 3000);

// REACT NATIVE ELEMENT
class DumbElement extends Component {
  constructor(props) {
    super(props);
    this.props.getHomePageTextbooks();
  }

  // @BUG: SHOULD UPDATE to '7'. IT NEVER HAPPENS
  render() {
    return <Text style={{ marginLeft: 50, marginTop: 100 }}>{this.props.data.length}</Text>
  }
}

const DumbElementRedux =
  connect(({ data }) => ({ data }), { getHomePageTextbooks })(DumbElement);

// APP
export default App = (props) => {
  return (
    <Provider store={store}>
      <DumbElementRedux />
    </Provider>
  )
}

I also created a repository and pushed it there. You can find it here: https://bitbucket.org/okazia/reactreduxbug6.0.0/

Read more comments on GitHub >

github_iconTop Results From Across the Web

Redux: Component is not updating after state is updated
The component will not update because the store.getState() inside of <div className="App"> will only run once when the component is called.
Read more >
Why React doesn't update state immediately
When developing React applications, you may have noticed that state updates don't immediately reflect new values after being changed.
Read more >
Why Redux Store Changes Don't Re-render - YouTube
When using Redux, it's common to run into issues where your store isn't updating, or isn't updating in the way you expect it...
Read more >
React Redux
Accidentally mutating or modifying your state directly is by far the most common reason why components do not re-render after an action has ......
Read more >
Reconciliation
When you use React, at a single point in time you can think of the render() function as creating a tree of React...
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