Data binding in React

前端 未结 12 778
心在旅途
心在旅途 2021-01-30 19:49

What I want to do is when I type some text in an input field, it should appear in another place realtime.

Below is my input;



        
12条回答
  •  温柔的废话
    2021-01-30 20:42

    Some modules makes simpler data-binding in forms, for example:

    react-distributed-forms

    class SomeComponent extends React.Component {
      state = {
        first_name: "George"
      };
    
      render() {
        return (
          
    ); } }

    https://www.npmjs.com/package/react-distributed-forms#data-binding

    It uses React context, so you don't have to wire together input in forms

    Here's a live demo

提交回复
热议问题