How to use props in a Class-based Component to display data

0 votes
With the help of code, can you tell me how to use props in a Class-based Component to display data?
Mar 24 in Node-js by Ashutosh
• 26,610 points
82 views

1 answer to this question.

0 votes

In a class-based React component, you can use props by accessing them via this.props. Here's a simple example:

import React, { Component } from "react";

class Greeting extends Component {
  render() {
    return <h1>Hello, {this.props.name}!</h1>;
  }
}

export default Greeting;
<Greeting name="Nidhi" />
answered Mar 24 by anonymous

Related Questions In Node-js

0 votes
1 answer
0 votes
1 answer

How to implement component lifecycle methods in a Class Component?

To implement component lifecycle methods in a ...READ MORE

answered Mar 26 in Node-js by anonymous
78 views
0 votes
1 answer

How to use host bindings to bind properties to the host element in a component?

In Angular (2+), the @HostBinding() decorator allows ...READ MORE

answered 5 days ago in Node-js by anonymous
49 views
0 votes
1 answer

How to use executables from a package installed locally in node_modules?

Hello @kartik, Use the npm bin command to get the ...READ MORE

answered Jul 13, 2020 in Node-js by Niroj
• 82,840 points
1,728 views
0 votes
1 answer
0 votes
1 answer

Why Is the Style Property Not Working in a Nested Paragraph Element?

CSS Specificity: If there's a more specific ...READ MORE

answered Dec 31, 2024 in HTML by Navya
140 views
0 votes
1 answer
0 votes
1 answer

How can props be passed using Link in React Router?

In React Router, you can pass data ...READ MORE

answered Feb 21 in Node-js by kavya
98 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
103 views
0 votes
1 answer
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