Tekkaman

导航

 

Controlled Components

  In HTML, form elements such as <input><textarea>, and <select> typically maintain their own state and update it based on user input. In React, mutable state is typically kept in the state property of components, and only updated with setState().

  We can combine the two by making the React state be the "single source of truth". Then the React component that renders a form also controls what happens in that form on subsequent user input. An input form element whose value is controlled by React in this way is called a "controlled component".

  

参考:https://facebook.github.io/react/docs/forms.html#controlled-components

posted on 2017-03-22 17:11  Tekkaman  阅读(166)  评论(0编辑  收藏  举报