react-redux-firebase
react-redux-firebase copied to clipboard
fix(HOCs): update Using UNSAFE_componentWillReceiveProps in strict mode warning with ^17.0.1
Bug report
Steps
Use firestoreConnect with [email protected] 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
Is there any solution on this? Its stopping me from using Strict Mode on my React project, despite having latest react-redux-firebase.
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....
Is there any solution? I'm trying to maintain old projects and facing this issue.
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?