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! πŸ”₯

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

πŸ‘‹ Kindness is contagious

Please leave a ❀️ or a friendly comment on this post if you found it helpful!

Okay