Languages
[Edit]
EN

React - render props

0 points
Created by:
Inayah-Alexander
407

In this article, we would like to show you how to render props in React functional components.

Below we create Container functional component which renders name and two children <div> elements passed as props.

Runnable example:

// ONLINE-RUNNER:browser;

// Note: Uncomment import lines while working with JSX Compiler.
// import React from 'react';
// import ReactDOM from 'react-dom';

const Container = ({name, children}) => {
return (
     <div>
       <div>{name}</div>
       <div>{children}</div>
     </div>
   );
};

const App = () => {
 return (
   <div>
     <Container name="Property name ...">
       <div>Children text ...</div>
       <div>Children text ...</div>
     </Container>
   </div>
 );
};

const root = document.querySelector('#root');
ReactDOM.render(<App />, root );

ReactJS

React - render props (functional component)
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join