-
Notifications
You must be signed in to change notification settings - Fork 46.9k
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
Add ability to remove/reset state back to null #2650
Conversation
|
Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla - and if you have received this in error or have any questions, please drop us a line at cla@fb.com. Thanks! |
Yes, that's exactly what I meant. There isn't any new method, you're able to reset it by calling |
@@ -48,6 +48,10 @@ describe('ReactCompositeComponent-state', function() { | |||
this.setState({color: nextColor}); | |||
}, | |||
|
|||
removeState: function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But you expose removeState
here...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't know you meant the test, I'll fix that. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oooh, it looked like it was exposed in the component. Then it's all good :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the confusion. :)
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks! |
I think we're leaning towards dropping support for replaceState. #3236 Dropping replacestate has been an ongoing discussion since January (#2843) Thanks for the PR though! If we were going to keep replaceState, I would say we should fix this behavior, because I agree with you, it's current implementation is inconsistent/wrong. That said, I'm going to close this PR, since I think it's likely we'll be removing replacestate, and it's better to do that in one hop, rather than changing behavior and then removing it anyway. |
As mentioned in #2572, replaceState(null) should set the state of component back to null.