官术网_书友最值得收藏!

  • The React Workshop
  • Brandon Richey Ryan Yu Endre Vegh Theofanis Despoudis Anton Punith Florian Sloot
  • 391字
  • 2021-06-11 18:28:30

Introduction – Talking to JavaScript with React

In the previous chapter, we designed our first standalone basic React application. The React framework allows you to create rich interactive web applications where users expect an interface that responds quickly to their actions. Often, when you are designing such interactive web applications, there is proper feedback expected within a fraction of a second for even a simple button click. Visualize this scenario:

you click a submit button after filling out a form on a web application, but nothing visible happens after you click the button.

From there, you might do one of two things, either sit and wait for some sort of feedback or furiously hit the button repeatedly, waiting for some sort of feedback or acknowledgment.

Now, you might get some feedback if the form redirects to a new page, or you might receive an error message with the form being submitted multiple times. In either of those scenarios, the developer who created that application has now created a user experience that feels nearly hostile to the end user, one that robs the user of valuable feedback and a way for them to understand how to properly use the application.

The good news is that these are all easily solvable problems in React. We can build our applications in a way that allows the users to be aware of each interaction they have with the site by providing some sort of feedback to the user so that they stay interested and use your application instead of giving up in frustration. You can start giving the user real-time feedback, gently guiding them along as they fill out the form and click the submit button or when they move the focus or cursor away from a field.

In this chapter, we are going to focus on how to intertwine our React components and JavaScript events in a way that really allows for the rich user experience on the web that most people expect nowadays. We will set up event listeners and handlers in our JSX code, and we will build functions in our components that will allow us to handle those events appropriately and change the state of our components. We will start off by designing how we want our component to function before we move into developing the code for the component.

主站蜘蛛池模板: 新野县| 高青县| 吉林市| 宁远县| 清流县| 灵寿县| 肥城市| 白河县| 通许县| 怀来县| 洪湖市| 平泉县| 元氏县| 苏州市| 定安县| 呼伦贝尔市| 丹东市| 潜江市| 临湘市| 泾川县| 巨鹿县| 庆安县| 巴彦县| 英超| 淮北市| 威海市| 朔州市| 黔南| 云南省| 花垣县| 神农架林区| 赣州市| 新巴尔虎右旗| 清徐县| 遂宁市| 灵宝市| 内丘县| 定安县| 灵寿县| 阳谷县| 乐亭县|