-
Notifications
You must be signed in to change notification settings - Fork 24
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
deprecated componentWillReceiveProps #25
Comments
I like cWRP though, because we have a nice separation between prop updates (content that may need to be truncated, cWRP) and internal state updates (needed for the truncation, cDU) |
The way you describe cWRP sounds like it could be replaced with Feel free to close this issue, or keep it as a reminder .. up to you! |
Hello everyone. Thank you for this nice little component. |
Yes @bitjoo, thanks for reminding me, I'll plan to take a look soon! |
|
So I did some digging, unfortunately not found a clean solution, but at least I can share what I've found. The
As sidenote, the component handles a case when receiving new props and at the same time the truncation (phase 2) is in progress. Initiating truncation when the previous one hasn't finished could lead to incorrect result. This make me think about questions where I don't really know the answer:
So IMO, the problem is that we need to distinguish what is the internal The only viable solution I could think of is using new For example the library could internally have 2 components class WrapperThatRerendersWithNewProps extends React.PureComponent {
render() {
return <TruncateMarkup
{...this.props}
key='new-key-for-every-rerender-that-effectively-remounts-TruncateMarkup'
/>
}
} Any be better ideas? There has to be something 😬 |
Yes, I believe having the library consumers to set I don't think the "updating with new props" case is something we need to support, mainly because I'm not aware of use cases where updating with new props is necessary, except maybe when fetching the data from server. But that should be handled by conditional rendering (rendering RTM only once the data is ready). For other use cases where the text changes dynamically, it's probably reasonable to expect a new Regarding your proposed |
IMHO, best solution would be to refactor to a functional component using useState and useEffect hooks |
React Strict Mode complains about this now:
If I'm reading the docs right, it looks like the main consequence is that the future React concurrent rendering feature won't work with unsafe lifecycles. |
i'm also getting the same warning @ramosbugs , any solutions? |
Any plan to address UNSAFE_componentWillReceiveProps issue? If someone in the community converts the class component to functional, would PR be reviewed and accepted? Or are we better off forking and releasing it under the new npm name? I use this package often so I might take time to help with this. |
Absolutely, I've taken a stab at it a while back when the deprecation was
announced but the functional component for RTM didn't work out because of
how the cWRP is used here. I haven't managed to get back to it so if you'd
like to help out, any PR is appreciated!
…On Fri, May 27, 2022, 07:03 Elisha Terada ***@***.***> wrote:
Any plan to address UNSAFE_componentWillReceiveProps issue? If someone in
the community converts the class component to functional, would PR be
reviewed and accepted? Or are we better off forking and releasing it under
the new npm name? I use this package often so I might take time to help
with this.
—
Reply to this email directly, view it on GitHub
<#25 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAHMCKIEYX7QUUISQR6IRDLVMBXSJANCNFSM4HFREZ6Q>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
I am not the maintainer but I've contributed to this repo a few times. IMHO if the new functional component works the same - accepting same props, displays the same result and does not introduce performance issues, I don't see why it shouldn't be merged. |
any changes we'll get a fix soon? |
this issue is yet happened. |
This does NOT need an immediate attention, but ..
Earlier in some minor version of react@16,
componentWillReceiveProps
and a few other methods were flagged asdeprecated
. The intention is to remove them completely in react@17.In this package, both
componentWillReceiveProps
andcomponentDidUpdate
do a lot of stuff, and I have no idea how complex it could be (if actually possible) to replace it by the new lifecycle methods. Btw. there is a polyfill for the new methods in older versions of react https://github.com/reactjs/react-lifecycles-compatIs there any plan to use the new lifecycle methods ?
As I said, this does not need to solved right now. However, it would be nice to have some idea about what's going to happen with this package once the release of react@17 is happening.
The text was updated successfully, but these errors were encountered: