In React, props (short for "properties") are the mechanism by which components communicate with each other. Just as HTML elements accept attributes to customize their behavior (<a href="https://example.com">), React components accept props passed down from parent components.
Props can be any valid JavaScript value: strings, numbers, booleans, objects, arrays, functions (callbacks), or even other React elements.
9// ✅ Correct Pattern: Derive new values or declare local variables
10functionProfile(props){
11const formattedName = props.name.toUpperCase();
12const nextCount = props.viewCount +1;
13
14return<div>{formattedName}({nextCount})</div>;
15}
If React permitted components to modify incoming props, child components could unexpectedly corrupt parent data structures, creating chaotic debugging nightmares across large applications.
4. Passing Non-String Props
Remember to enclose non-string values (numbers, booleans, objects, arrays) in curly braces:
JSX
1// Strings can use regular quotes
2<Badgetext="Pro Member"/>
3
4// Numbers, booleans, objects, and arrays MUST use curly braces