prescottprue / react-redux-firebase

Redux bindings for Firebase. Includes React Hooks and Higher Order Components.
https://react-redux-firebase.com
MIT License
2.55k stars 558 forks source link

fix(HOCs): update Using UNSAFE_componentWillReceiveProps in strict mode warning with ^17.0.1 #1059

Open LuisMerinoP opened 3 years ago

LuisMerinoP commented 3 years ago

Bug report

Steps

Use firestoreConnect with react-redux-firebase@3.10.0 and react@^17.0.1 in a project with react strict mode. Open your console to see the warnings

Expected Result

No warnings should appear even with react strict mode.

Actual Result:

    Warning: Using UNSAFE_componentWillReceiveProps in strict mode is not recommended and may indicate bugs in your code. See https://reactjs.org/link/unsafe-component-lifecycles for details.

    * Move data fetching code or side effects to componentDidUpdate.
    * If you're updating state whenever props change, refactor your code to use memoization techniques or move it to static getDerivedStateFromProps. Learn more at: https://reactjs.org/link/derived-state

    Please update the following components: FirestoreConnectWrapped(Dashboard)

This is the code producing the warning:

    [export default compose<React.FunctionComponent>(
      connect(mapStateToProps),
      firestoreConnect([
        { collection: 'projects' }
      ])
    )(Dashboard);

codesandbox link

nirmalhk7 commented 3 years ago

Is there any solution on this? Its stopping me from using Strict Mode on my React project, despite having latest react-redux-firebase.

LuisMerinoP commented 3 years ago

I think that the options are to dive into the code and check if the HOC can be fixed and for pull request, wait until its fixed, which does not seem immediate, or use a react hook to set the listener to the database yourself, that would involve change the approach for that specific component to remove the usage of redux replace by a react hook...this involves also the presumable propagation of hooks usage in your app, as you will need to make this replacement for all the components that need to listen to the database info....

mastercodingbear commented 1 year ago

Is there any solution? I'm trying to maintain old projects and facing this issue.

vlladislav45 commented 1 year ago

Hi, I have the same issue in React 18.2.0. I would like to know if this dependency will continue to refining, do you?