You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
However, the div element is not the best choice for a button. So, I would suggest replacing it with a button element.
I would be glad to create a pull request if you don't mind 😃 @sudheerj
The text was updated successfully, but these errors were encountered:
dolgachio
changed the title
Add semantic tag to example for 5. What is the difference between Element and Component?
Use a semantic tag instead of a div in an example for 5. What is the difference between Element and Component?
Nov 22, 2024
A React element is an object that describes a DOM node (or another component) and its properties. It’s what React uses to build the user interface. When you use JSX syntax, like <div id="login-btn">Login</div>
it’s converted into a React element. The element itself is a lightweight, immutable description of what to render.
A React component is a function or class that can accept inputs (called "props") and returns a React element. Components are the building blocks of a React application, and they can manage state, lifecycle methods, and more. For instance, the Button function you shared is a component. It takes handleLogin as a prop and renders a div element (or a button element, as you suggested).
@anup4747 you are right, but from the HTML semantic standpoint <div> tag should not be a button.
in this example, an element has login-btn id and onClick handler.
Desccription
If you open
5. What is the difference between Element and Component?
the example code is:
However, the
div
element is not the best choice for a button. So, I would suggest replacing it with abutton
element.I would be glad to create a pull request if you don't mind 😃 @sudheerj
The text was updated successfully, but these errors were encountered: