Skip to content

Detailed Answer added with example in Question 218 #255

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4917,13 +4917,25 @@

218. ### How to pass numbers to React component?

You should be passing the numbers via curly braces({}) where as strings in quotes
We can pass `numbers` as `props` to React component using curly braces `{}` where as `strings` in double quotes `""` or single quotes `''`

```jsx
React.render(
<User age={30} department={"IT"} />,
document.getElementById("container")
);
import React from "react";
const ChildComponent = ({ name, age }) => {
return (
<>
My Name is {name} and Age is {age}
</>
);
};
const ParentComponent = () => {
return (
<>
<ChildComponent name="Chetan" age={30} />
</>
);
};
export default ParentComponent;
```

**[⬆ Back to Top](#table-of-contents)**
Expand Down