Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Web Technology by (55.6k points)

Can anyone please explain the state with an example in React JS?

1 Answer

0 votes
by (119k points)
edited by

State in React JS is an object that stores the prop values of the components and can store as many properties as we want. 

Here is an example of State in React JS

class Car extends React.Component {

 constructor(props) {

    super(props);

    this.state = {

        brand: “Ferrari”

       year: “1992”

       color: “silver”

     };

 }

 render() {

    return (

      <div>

        <h1>My Car Details</h1>

     </div>

    );

 }

}

If you are interested in web development, you can enroll these Web development courses by Intellipaat

Do check out this Full Stack Developer Online Course to help you enhance your career.

You can watch this video on React JS course for beginners to learn about State with example in React JS:

Thinking of getting a certification in React JS? Here is the React Course for you to enroll in!

Related questions

0 votes
1 answer
0 votes
1 answer
asked Mar 27, 2020 in Web Technology by Sudhir_1997 (55.6k points)
0 votes
1 answer
asked Nov 4, 2020 in Web Technology by Sudhir_1997 (55.6k points)
0 votes
1 answer
asked Mar 27, 2020 in Web Technology by Sudhir_1997 (55.6k points)
0 votes
1 answer
asked Nov 4, 2020 in Web Technology by Sudhir_1997 (55.6k points)

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...