Skip to content

connect swallows errors in mapStateToProps (new bug in 8.0.0) #1942

Open
@grumd

Description

@grumd

What version of React, ReactDOM/React Native, Redux, and React Redux are you using?

  • React: 18.2
  • ReactDOM/React Native: react-dom 18.2
  • Redux: 4.2.0
  • React Redux: 8.0.2

What is the current behavior?

https://codesandbox.io/s/gifted-architecture-wr4f86?file=/src/App.js

  1. Have a code that can cause an error in mapStateToProps, e.g.
const mapStateToProps = (state) => {
  return {
    foo: state.foo.length, // when foo is undefined, causes an error
  };
};
  1. Dispatch an action that changes the state so that it causes the error above
dispatch(updateFoo(undefined));
  1. Rerender doesn't happen, no errors emitted in console, componentDidCatch catches nothing. The error is swallowed.

What is the expected behavior?

This issue makes debugging code that's using react-redux really hard.
The expected behaviour is that the error is visible in console.
It worked fine in 7.2.8: https://codesandbox.io/s/charming-firefly-coekps
image

Which browser and OS are affected by this issue?

Windows, latest Chrome here. Probably affects all browsers.

Did this work in previous versions of React Redux?

  • Yes

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions