Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ReactJS(jsx) Passing Parameters

I am new to react and I was wondering why does the parameter (a) need to be passed with variables e.g a.amount, a.date. What is the process and reasoning behind this?

like image 463
Ayaan Abbasi Avatar asked Oct 19 '25 19:10

Ayaan Abbasi


1 Answers

The general name for it "props" (in your component it is "a").

"Props" is an object that has all the properties passed to the component.

For example;

<ExampleComponent isEnabled={true} isClickable={false} />

Then you can access those properties in your component in two ways;

1: Get the prop variable and use it an object as you do in your example. 2: Destruct the object in your component to use as you want.

const ExampleComponent = ({isEnabled, isClickable}) => {
    return "<></>";
});

For more information:

https://reactjs.org/docs/components-and-props.html

like image 172
Canser Yanbakan Avatar answered Oct 22 '25 09:10

Canser Yanbakan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!