15 - Summary Building Components
15 - Summary Building Components
Building Components
Terms
Fragment
Immutable
Props
State hook
Summary
• In React apps, a component can only return a single element. To return multiple
elements, we wrap them in a fragment, which is represented by empty angle brackets.
• To render a list in JSX, we use the ‘array.map()’ method. When mapping items, each
item must have a unique key, which can be a string or a number.
• We use the state hook to de ne state (data that can change over time) in a component. A
hook is a function that allows us to tap into built-in features in React.
• Components can optionally have props (short for properties) to accept input.
• We can pass data and functions to a component using props. Functions are used to
notify the parent (consumer) of a component about certain events that occur in the
component, such as an item being clicked or selected.
• When the state or props of a component change, React will re-render the component
and update the DOM accordingly.
• In React apps, a component can only return a single element. To return multiple
elements, we wrap them in a fragment, which is represented by empty angle brackets.
• To render a list in JSX, we use the ‘array.map()’ method. When mapping items, each
item must have a unique key, which can be a string or a number.
• We use the state hook to de ne state (data that can change over time) in a component. A
hook is a function that allows us to tap into built-in features in React.
• Components can optionally have props (short for properties) to accept input.
• We can pass data and functions to a component using props. Functions are used to
notify the parent (consumer) of a component about certain events that occur in the
component, such as an item being clicked or selected.
• When the state or props of a component change, React will re-render the component
and update the DOM accordingly.
CREATING A COMPONENT
RENDERING A LIST
CONDITIONAL RENDERING
HANDLING EVENTS
DEFINING STATE
PROPS
PASSING CHILDREN