Reactjs

How to Change text with reactjs click event?

Change text with reactjs click event

Views

Hello, welcome to therichpost.com. In this post, I will tell you, How to Change text with reactjs click event? Reactjs is a Javascript Library to build user interface.

Here is the working code for Here is the working for React js Onclick Event Handler Example and you can add this into your index.js file: and you can add this into your index.js file:
import React from 'react';
import ReactDOM from 'react-dom';

class Hello extends React.Component{
  constructor()
  {
    super();
      this.state =  {
         title: "Click Me"
      }
  }
  render()
  {
    return (
     <h1 onClick={ () => this.setState({ title: "New title" })}>{this.state.title}</h1>
    )
  }
}

ReactDOM.render(<Hello />, document.getElementById('root'));

  If you have any query related to this post then please do ask in below comment section and I will come with more post related to reactjs.

Ajay Malhotra
the authorAjay Malhotra
Hello to all. Welcome to therichpost.com. Myself Ajay Malhotra and I am full stack developer. I love coding. I know Wordpress, Core php, Angularjs, Angular 2, Angular 6, Angular 7, laravel, Codeigniter, Shopify, Squarespace, Jquery, Google Map Api, Vuejs, Reactjs, Bigcommerce etc.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Positive SSL