React Practice

When we use React to process form elements, there are generally two ways: controlled components and uncontrolled components.

1. Controlled form component: React binds the state and the form value together, and state value controls the form value, thus ensuring the characteristics of a single data source. First, we need to declare a component's state data and then set it as the value of the input element. Then we add a change event to the input, and in the event handler, we get the value of the current text box through the event object 'e'. Finally, we call the setState method to use the value of the text box as the latest value of the state.

2. The uncontrolled form component obtains the value of the text box by manually manipulating the DOM. The 'state' does not control the state of the text box in the react component, and the input value is obtained directly through the DOM. #programming #jracademy

要查看或添加评论,请登录

Alyson Qian的更多文章

  • project reflection

    project reflection

    Our team developed a web application using the React framework for task management. The site allows users to create…

  • Using APIs

    Using APIs

    Today, I had an exciting experience using RapidAPI to fetch YouTube video information and render it on a React project.…

  • React learning

    React learning

    Today I used the useState() and useEffect() hooks in React to create a small movie search page using the OMDb API…

  • Project reflection

    Project reflection

    Implementing email verification using MongoDB and Node.js was a challenging yet rewarding experience.

  • Project Reflection

    Project Reflection

    This week I am responsible for the task of email verification. The basic flow of developing an email verification…

  • Project Reflection

    Project Reflection

    Working on a React group project has been a great experience for our team. Throughout this project, we have learned the…

  • React learning

    React learning

    When I first started learning React projects, it was a bit overwhelming because of the amount of information and tools…

  • project process

    project process

    From the beginning of the project to the present, we have completed almost all front-end and some back-end development…

  • Project process

    Project process

    After I finished two front-end tasks in the group project, I took on a back-end email verification task. I was a bit…

  • project reflection

    project reflection

    Today, I learned the use of MongoDB through the case of Books SCHEMA and the standard commands of databases in the…

社区洞察

其他会员也浏览了