redux-zero / redux-zero

A lightweight state container based on Redux

Home Page:https://matheusml1.gitbooks.io/redux-zero-docs/content/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

react waning for <Connect>

axetroy opened this issue · comments

componentWillMount has been renamed

react-dom.development.js:12357 Warning: componentWillMount has been renamed, and is not recommended for use. See https://fb.me/react-unsafe-component-lifecycles for details.

* Move code with side effects to componentDidMount, and set initial state in the constructor.
* Rename componentWillMount to UNSAFE_componentWillMount to suppress this warning in non-strict mode. In React 17.x, only the UNSAFE_ name will work. To rename all deprecated lifecycles to their new names, you can run `npx react-codemod rename-unsafe-lifecycles` in your project source folder.

Please update the following components: Connect

The class component should be removed, use function component instead

@axetroy how did you fix it? I have a component which has:
import { connect } from "redux-zero/react";
// code
export default connect(mapToProps, actions)(LoginForm);

We could definitely rewrite the Connect class to use the hooks API.
Could you please open that PR?

Any updates here? The warning is still there.

react-dom.development.js:88 Warning: componentWillMount has been renamed, and is not recommended for use. See https://fb.me/react-unsafe-component-lifecycles for details.

Please update the following components: Connect

Yes, I'm totally willing to accept this PR.

Is the update coming anytime soon?

It's done, please update with latest (5.1.4)

@matheusml I just updated it, but it seems we continue with the same issues.

image

@matheusml I just updated it, but it seems we continue with the same issues.

image

I updated to 5.1.4 today and it works fine for me. No warnings.

Maybe you are missing something.

Seems like in <React.StrictMode> you can't even use the UNSAFE methods. Didn't know about that.

Either way, there's an open issue for us to properly solve this.

My advice for you is to try to replace connect/Connect with the new hooks API.
In 5.2.0 (which will be shipped today) the change is straightforward. Everything will remain the same, except for the connect/Connect, that will be replaced by useSelector and useActions

By removing the StrictMode the errors disappeared indeed. That's fine then 👍