--- title: Tabs tags: components,state,children cover: by-the-lighthouse firstSeen: 2019-01-27T11:59:52+02:00 lastUpdated: 2021-10-13T19:29:39+02:00 --- Renders a tabbed menu and view component. - Define a `Tabs` component. Use the `useState()` hook to initialize the value of the `bindIndex` state variable to `defaultIndex`. - Define a `TabItem` component and filter `children` passed to the `Tabs` component to remove unnecessary nodes except for `TabItem` by identifying the function's name. - Define `changeTab`, which will be executed when clicking a ` ))}
{items.map(({ props }) => (
))}
); }; ``` ```jsx ReactDOM.createRoot(document.getElementById('root')).render( Lorem ipsum Dolor sit amet ); ```