- Forums
- react
- How To Pass Props In React Component A Very Simple Example
How To Pass Props In React Component A Very Simple Example MathHome Component Addition Component subject=Addition [5105], Last Updated: Mon Jun 24, 2024
dd
Thu Mar 23, 2023
0 Comments
269 Visits
This is how you would pass a Props value to a component in a react applicaiton.
App.js
Import the component:
import Addition from './Addition';
Include the component in your JSX:
<Addition subject="Addition" />
Component called Addition.jsx
function Addition(props) {
let subject = props.subject;
return (
<div>
<h1>Addition Component subject={subject}</h1>
</div>
)
}
export default Addition
Output: Addition Component subject=Addition
Hope this helps