--- title: Tabs type: snippet language: react tags: [components,state,children] cover: by-the-lighthouse dateModified: 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 ); ```