React Foundations Flashcards
(20 cards)
What is React?
A JavaScript library for building user interfaces
What is JSX?
A syntax extension for JavaScript that lets you write HTML-like code in React.
What is a component in React?
An independent
What is the difference between functional and class components?
Functional components are simpler and use hooks; class components use lifecycle methods.
What is state in React?
A built-in object that stores property values that belong to a component.
What is a prop in React?
Short for properties
How do you pass data from a parent to a child component?
By using props.
What is useState used for?
To declare and update state in functional components.
What is useEffect used for?
To handle side effects such as data fetching
What happens when state is updated?
React re-renders the component to reflect the new state.
What is the virtual DOM?
A lightweight copy of the real DOM used by React to improve performance.
What is the key prop and why is it important?
It helps React identify which items have changed in a list.
Can props be changed inside a component?
No
What is lifting state up?
Moving state to a common ancestor to share it between components.
What does conditional rendering mean in React?
Rendering components or elements based on a condition.
How do you handle events in React?
Using camelCase syntax and passing functions
What is a controlled component?
A form input element controlled by React state.
What is the difference between controlled and uncontrolled components?
Controlled components are tied to state; uncontrolled components use refs and manage their own state.
How do you perform form validation in React?
By controlling input values via state and adding custom validation logic.
What does ReactDOM.render() do?
It renders a React element into the DOM in the supplied container.