Props - Next Js App Directory 13.4

Bayu Setiawan - Sep 14 '23 - - Dev Community

What is Props?

Props are arguments passed into React components from parent to the child component

Parent component in App.jsx

function App() {
  return (
    <div className="App">
      <ChildComponent productName="Laptop" productPrice={5000000} />
    </div>
  );
}
export default App;
Enter fullscreen mode Exit fullscreen mode

Child component in ChildComponent.jsx

const ChildComponent = props => {
  return (
    <div>
      <p>Product Name: {props.productName}</p>
      <p>Price: Rp{props.productPrice}</p>
    </div>
  );
};
export default ChildComponent;

Enter fullscreen mode Exit fullscreen mode

in this example we sent productName and productPrice from App.jsx to ChildComponent.jsx

Hope this helps!

. . . . . . . . . . .
Terabox Video Player