Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

react pass component as props

function Parent({children}) {
  return (
    <div>
      {children}
    </div>
  );
}

export default function App() {
  const Title = () => {
    return <h2>Hello world</h2>;
  };
  
  return (
    <div>
      <Parent>
        <Title />
      </Parent>
    </div>
  );
}
Source by bobbyhadz.com #
 
PREVIOUS NEXT
Tagged: #react #pass #component #props
ADD COMMENT
Topic
Name
8+4 =