GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Warn when value and defaultValue props are both specified on input or textarea. by michaelgmcd · Pull Request #5823 · react/react

Conversation

@michaelgmcd

@michaelgmcd michaelgmcd commented Jan 11, 2016

Copy link
Copy Markdown
Contributor

Fixes #5819.

Note that I've been using React for a while but this is my first time contributing.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@michaelgmcd michaelgmcd changed the title Warn when value and defaultValue prop is specified on input or textarea. Warn when value and defaultValue props are both specified on input or textarea. Jan 11, 2016
@facebook-github-bot facebook-github-bot added GH Review: review-needed CLA Signed labels Jan 11, 2016
jimfb
jimfb reviewed Jan 11, 2016
View reviewed changes
Comment thread src/renderers/dom/client/wrappers/ReactDOMInput.js Outdated

@jimfb jimfb Jan 11, 2016

Copy link
Copy Markdown
Contributor

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.

The first sentence in this error message makes it sound like neither of the props should be specified. It says "both... props... should not be specified". Alternative wording:

Input elements must be either controlled or uncontrolled (specify either the value prop, or the defaultValue prop, but not both). Decide between using a controlled or uncontrolled input and remove one of these props. More info: https://fb.me/react-controlled-components

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@jimfb

jimfb commented Jan 11, 2016

Copy link
Copy Markdown
Contributor

@mgmcdermott This looks really great! Can you update the wording of the error messages, as per above, and then I think this is good-to-go.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@michaelgmcd

michaelgmcd commented Jan 11, 2016

Copy link
Copy Markdown
Contributor Author

See the new PR. Glad I could help @jimfb. Nice to get my feet wet contributing as well.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jimfb

jimfb commented Jan 11, 2016

Copy link
Copy Markdown
Contributor

Looks good.

Can you squash these two commits into a single commit. You can do this using git rebase -i and then squashing, then do a git push -f to update the branch. We generally like single-commit PRs, because it makes things easier to revert if/when necessary.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jimfb

jimfb commented Jan 11, 2016

Copy link
Copy Markdown
Contributor

Oh, sorry, and one more thing I just noticed: defaultChecked is also a react prop, we should do the same check for that - can't specify both checked and defaultChecked.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@michaelgmcd

michaelgmcd commented Jan 11, 2016

Copy link
Copy Markdown
Contributor Author

I'll update to include checked/defaultChecked.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@facebook-github-bot

facebook-github-bot commented Jan 11, 2016

Copy link
Copy Markdown
Contributor

@mgmcdermott updated the pull request.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@michaelgmcd

michaelgmcd commented Jan 11, 2016

Copy link
Copy Markdown
Contributor Author

Would this also apply to a select element using the value and defaultValue props?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@michaelgmcd

michaelgmcd commented Jan 11, 2016

Copy link
Copy Markdown
Contributor Author

Changed my comment, I meant a select element. From the source: Implements a select native component that allows optionally setting the props value and defaultValue.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jimfb

jimfb commented Jan 11, 2016

Copy link
Copy Markdown
Contributor

Yes, this should also apply to select element :).

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@michaelgmcd
Warn when both value and defaultValue or both check and defaultChecke…
f2b62e9
…d props are specified on input, textarea, or select elements
@michaelgmcd

michaelgmcd commented Jan 11, 2016

Copy link
Copy Markdown
Contributor Author

See the latest PR, I think I've covered everything.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@facebook-github-bot

facebook-github-bot commented Jan 11, 2016

Copy link
Copy Markdown
Contributor

@mgmcdermott updated the pull request.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jimfb

jimfb commented Jan 11, 2016

Copy link
Copy Markdown
Contributor

This looks great, thanks @mgmcdermott!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jimfb jimfb added GH Review: accepted and removed GH Review: review-needed labels Jan 11, 2016
jimfb added a commit that referenced this pull request Jan 11, 2016
@jimfb
Merge pull request #5823 from mgmcdermott/master
171305f
Warn when value and defaultValue props are both specified on input or textarea.
@jimfb
jimfb merged commit 171305f into react:master Jan 11, 2016
@jimfb

jimfb commented Jan 11, 2016

Copy link
Copy Markdown
Contributor

@mgmcdermott If you're looking for another bug related to controlled inputs, you might take a stab at #5821, which would be a great next bug.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@michaelgmcd

michaelgmcd commented Jan 11, 2016

Copy link
Copy Markdown
Contributor Author

Will do! Thanks.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@zpao zpao mentioned this pull request Jan 12, 2016
Fixup style for long lines #5829
Merged
@renovate renovate Bot mentioned this pull request Feb 2, 2018
Update dependency react to v0.14.9 - autoclosed signavio/backbone-rel#29
Closed
1 task
@coderabbitai coderabbitai Bot mentioned this pull request Jun 16, 2026
sdds-sbcom: Развернуть документацию salute-developers/plasma#2883
Merged
mrizwanashiq pushed a commit to mrizwanashiq/react that referenced this pull request Jun 25, 2026
@jimfb
Merge pull request react#5823 from mgmcdermott/master
b6ac4fe
Warn when value and defaultValue props are both specified on input or textarea.
@coderabbitai coderabbitai Bot mentioned this pull request Jul 2, 2026
feat(storybook): Storybook 10 + Vite + Storybook MCP, atomic story coverage OpenResilienceInitiative/ORISO-Frontend#336
Merged
hanzo-dev pushed a commit to hanzoai/react that referenced this pull request Sep 9, 2026
@jimfb
Merge pull request react#5823 from mgmcdermott/master
ac37a71
Warn when value and defaultValue props are both specified on input or textarea.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

CLA Signed

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@michaelgmcd @jimfb @facebook-github-bot
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.