How to pass props to a component and access them

0 votes
Can you tell me How to pass props to a component and access them?
12 hours ago in Node-js by Nidhi
• 12,380 points
16 views

1 answer to this question.

0 votes

To pass props to a component and access them:

Example:

// Parent Component

import React from 'react';

import Greeting from './Greeting';

const App = () => {

  return <Greeting name="John" />;

};

export default App;

// Child Component (Greeting.js)

import React from 'react';

const Greeting = (props) => {

  return <h1>Hello, {props.name}!</h1>;

};

export default Greeting;

answered 10 hours ago by Dua

Related Questions In Node-js

0 votes
1 answer

How to update a value in a json file and save it through node.js?

//install ciql-json : npm i ciql-json const ciqlJson ...READ MORE

answered May 26, 2021 in Node-js by Sirus

edited Mar 5 26,196 views
0 votes
1 answer

How to split and modify a string in NodeJS?

Hello @kartik, Use split and map function: var str = "123, 124, 234,252"; var ...READ MORE

answered Oct 16, 2020 in Node-js by Niroj
• 82,840 points
1,398 views
0 votes
1 answer

How are default props declared in a React functional component?

In React functional components, default prop values ...READ MORE

answered Feb 21 in Node-js by kavya
69 views
0 votes
1 answer

How to use interceptors to modify HTTP requests and responses in Angular?

In Angular, interceptors are used to modify ...READ MORE

answered 10 hours ago in Node-js by Anvi
13 views
0 votes
1 answer

How to unsubscribe from an observable to prevent memory leaks in Angular?

In Angular, unsubscribe from observables to prevent ...READ MORE

answered 10 hours ago in Node-js by Anvi
11 views
0 votes
1 answer
0 votes
1 answer

How to create a simple React Element displaying "Hello, World!"?

You can create a simple React element ...READ MORE

answered 10 hours ago in Node-js by Anvi
11 views
0 votes
1 answer

How to schedule a google meet and get the meet link in NodeJs?

To create a Google Meet, you'll need ...READ MORE

answered May 27, 2022 in Node-js by Neha
• 9,020 points
4,112 views
0 votes
1 answer

How to pass request query parameters through a Node.js application?

Using Node.js http Module Step 1: Basic Server ...READ MORE

answered Dec 13, 2024 in Node-js by Navya
113 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP