Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Auto-save text written in DismissibleTextForm #6884
Auto-save text written in DismissibleTextForm #6884
Changes from all commits
9565b44
c604aa7
8e3de9d
cec3498
fa04ee6
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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 honestly don't know how this worked before but it did. I read the
react-textarea-autosize
source twice. I have no idea! It no longer works with my new call tosetState({ text: ... })
but I don't know what's different. In any case, it should have always been setting thevalue
prop, notdefaultValue
.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.
That's an uncontrolled component, no? https://reactjs.org/docs/uncontrolled-components.html#default-values A weird one though, like a semi-controlled/semi-uncontrolled component 😄
Since you can supply any props to
Textarea
and therefore to the underlyingtextarea
, thatdefaultValue
prop is passed to thetextarea
and thetextarea
becomes an uncontrolled component. In theory, one would need to use aref
to read thetextarea
content but... theTextarea
component implements anonChange
handler on the underlyingtextarea
.According to the code,
onChange
is always called inTextarea
: https://github.com/andreypopp/react-textarea-autosize/blob/f4f49e84c4beccf29188c72c2a3b21899bc0e85a/src/index.js#L113, so theonTextChange
callback is also always called, and when it updates the state, thedefaultValue
gets updated too (because of the re-render).The implementation of
onChange
inTextarea
is not correct IMO, it should early return inif (!this._controlled) { ... }
, so that developers would know thatdefaultValue
andonChange
don't play nice together.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.
👍