Skip to content

controlled components made uncontrolled #16

Closed

Description

@hallgren

Is there any way that a controlled component can be updated or made uncontrolled?

For example the <input type="submit" value="Send"/> will not update its value on a new value on render.

Activity

  1. ssorallen commented on Feb 1, 2015

    @ssorallen
    Contributor

    I changed that in a pull request that was merged to master, but the commits have not yet been included in a release: #15

    The PR also changed checked to defaultChecked for the same reason you mentioned.

  2. Daniel15 commented on Feb 1, 2015

    @Daniel15
    Contributor

    Are you using react-magic or HTMLtoJSX?

    Thanks for the reminder @ssorallen, I'll cut a release shortly. I was going to bundle some other bug fixes but I can do those separately.

  3. Daniel15 commented on Feb 1, 2015

    @Daniel15
    Contributor

    Just pushed out an update to HTMLtoJSX. As for react-magic, it should already be up to date.

  4. ssorallen commented on Feb 1, 2015

    @ssorallen
    Contributor

    @Daniel15, where does HTMLtoJSX live? I thought it was part of react-magic.

  5. Daniel15 commented on Feb 1, 2015

    @Daniel15
    Contributor

    HTMLtoJSX is the package on NPM, and is one portion of react-magic. It handles converting HTML to JSX, that's it.

    React-magic is HTMLtoJSX + automatically converting the whole page to a React component + handling AJAX loading page transitions (ie. clicking URLs). React-magic is more experimental :P

    The readme in this repo explains what react-magic is, whereas README-htmltojsx.md (and the readme on NPM) explain HTMLtoJSX.

  6. Daniel15 commented on Feb 1, 2015

    @Daniel15
    Contributor
  7. ssorallen commented on Feb 1, 2015

    @ssorallen
    Contributor

    Cool, thanks for the explanation. I see the new 0.2.1 package on NPM.

  8. hallgren commented on Feb 1, 2015

    @hallgren
    Author

    defaultValue will not work on all types including type="submit" according to the react team it´s a button and not editable by a user. ref: react/react#2673 (comment)

    Is it possible to work around this in HTMLtoJSX? I think and I have the issue that a submit button value can change between two diffing HTML elements.

  9. ssorallen commented on Feb 1, 2015

    @ssorallen
    Contributor

    Good point on the value of a <input type="submit">. It seems to work fine setting defaultValue though, even if it's not semantically meaningful.

  10. Daniel15 commented on Feb 1, 2015

    @Daniel15
    Contributor

    If setting defaultValue rather than value on buttons doesn't work properly, I'd suggest opening a separate issue for it. Thanks!

  11. ssorallen commented on Feb 1, 2015

    @ssorallen
    Contributor

    @hallgren Aha, I see what you mean by the problem now. First page has an <input type="submit" value="Submit"> and the second one has <input type="submit" value="Click Me">, and the value would not be reflected in the rendered DOM because HTMLtoJSX is setting defaultValue instead of value.

  12. hallgren commented on Feb 1, 2015

    @hallgren
    Author

    I don´t know if it´s possible to update the value on the submit button due to how react.js handles the <input type="submit"> button component.

    It work for the <button type="submit">text</button> tag.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      ⌂ Proxy