react-elements Flashcards
1
Q
What is React?
A
A JS library for building user interfaces. Efficiently updates and renders the right components based on state. Encapsulated components that manage their own state. Works on Node and can make mobile apps with React Native.
2
Q
What is a React element?
A
The smallest building blocks of React apps. They describe what you want to see on the screen written in XML and HTML. They are plain objects that are cheap to create and immutable meaning once it is made you cannot change its children or attributes.
3
Q
How do you mount a React element to the DOM?
A
- Query the DOM for a div with id root which you put inside the body and save it to a const variable (container)
- Call the method ReactDOM.createRoot(container) with the DOM element with id root.
- Assign the return of the above method to a const variable (root)
- Call the method React.createElement(type, optional props, text content or children)
- Assign the return of the above method to a const variable (el)
- Call the method root.render(el) where root is from step 3, and el is from step 5