(Beginner) I have a question regarding react.

Asked 2 years ago, Updated 2 years ago, 83 views

Good afternoon

I'm a new developer who studied Java.

I got interested in reaction, so I'm watching it little by little, and I have a question

We created a function that handles buttons and events as shown above by configuring the front of the react.

Run it as yarn start, click the button to check the alert window, and check the page source well.

I have a question because I can't find that function no matter how much I look for it.

I know that dynamic processing is possible only when there is JavaScript in static HTML, but on the page

Only click is checked, and the onClick attribute is not visible.

In react, we learned that we use webpack to create bundle.js by using the component, bundle.js, and bring JavaScript together, so we checked bundle.js with Chrome developer mode source, but we can't see the function that handles the event.

I want to know where that function is hiding and how it detects button event processing.

Please give me some advice

react

2022-09-22 11:52

1 Answers

React is using virtual DOM.

JSX, which looks like an HTML tag with a return value, is exposed to the actual DOM tree, but it is managed internally by React. It's easy to understand if you think it's mapped to a real DOM (hereinafter referred to as a real DOM), which is actually rendered (although not all JSX tags are like that).

Events are also internally detected and processed without directly dialing into native DOM events. Because of this, we specified onClick as inline in JSX, but it is actually processed internally in react and is not visible in real DOM. Instead, the real DOM exposes HTMLElement processed to allow external click events to be dispatched inside.


2022-09-22 11:52

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.