• Struts
  • Core Java
  • JavaScript
  • Spring
  • Java IO
  • JSP
  • Servlet
  • SQL Tutorial
  • PHP

  • <

    Reactjs Events

    React has its own event handling system which is very similar to handling events on DOM elements.React perform actions based on user events.React has the same events as HTML.


    Example



    app.jsx
    
    
    import React from 'react';
    
    class App extends React.Component {
       constructor(props) {
          super(props);
          
          this.state = {
             data: 'Initial data...'
          }
          this.updateState = this.updateState.bind(this);
       };
       updateState() {
          this.setState({data: 'Data updated...'})
       }
       render() {
          return (
             <div>
                <button onClick = {this.updateState}>CLICK</button>
                <h4>{this.state.data}</h4>
             </div>
          );
       }
    }
    export default App;
    


    main.js
    
    
    import React from 'react';
    import ReactDOM from 'react-dom';
    import App from './App.jsx';
    
    ReactDOM.render(<App/>, document.getElementById('app'));
    
    
















    © copyright 2017-2021 Completedone pvt ltd.