Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

React.createFactory has been deprecated since v16.13.0 but react-toastr still uses it #139

Open
pocke opened this issue Mar 3, 2020 · 2 comments

Comments

@pocke
Copy link

pocke commented Mar 3, 2020

Problem

React.createFactory has been deprecated since React v16.13.0.
https://github.com/facebook/react/releases/tag/v16.13.0
https://reactjs.org/docs/react-api.html#createfactory

But react-toastr uses createFactory function, so it causes a warning.

Warning: React.createFactory() is deprecated and will be removed in a future major release. Consider using JSX or use React.createElement() directly instead.

toastMessageFactory: React.createFactory(ToastMessageAnimated),

Solution idea

I think we can just replace it with a function component.
For example:

- toastMessageFactory: React.createFactory(ToastMessageAnimated), 
+ toastMessageFactory: (props) => <ToastMessageAnimated {...props} />,

The React documentation also recommends this solution.

This helper is considered legacy, and we encourage you to either use JSX or use React.createElement() directly instead.
https://reactjs.org/docs/react-api.html#createfactory

If you like this idea, I'll open a pull request with the patch.

Thanks!

@MarkEhr
Copy link

MarkEhr commented Mar 18, 2020

This project seems abandoned. I think the best solution would be to fork it and try to maintain it on another branch.

pocke added a commit to bitjourney/react-toastr that referenced this issue Oct 26, 2020
@pocke
Copy link
Author

pocke commented Oct 29, 2020

I've created a fork version of react-toastr as @bitjourney/react-toastr for React v17.
https://github.com/bitjourney/react-toastr
https://www.npmjs.com/package/@bitjourney/react-toastr

We use the forked package, but we still use React v16 due to another problem.

I do not have a plan to maintain the forked package for the long term because we're considering switching another toast library from react-toastr. So, I recommend creating another fork if someone wants to maintain it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants