react-toastr
react-toastr copied to clipboard
React.createFactory has been deprecated since v16.13.0 but react-toastr still uses it
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.
https://github.com/tomchentw/react-toastr/blob/fcd3b4b7e6031dde7c128921489bffaad85729a9/src/components/ToastContainer.jsx#L49
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!
This project seems abandoned. I think the best solution would be to fork it and try to maintain it on another branch.
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.