DEV Community

Cover image for Props - Next Js App Directory 13.4
Bayu Setiawan
Bayu Setiawan

Posted on

Props - Next Js App Directory 13.4

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!

Top comments (1)

Collapse
 
codebayu profile image
Bayu Setiawan

Hi, kindly leave a like and comment if you got new insight! 🔥