• Java IO
  • jQuery
  • Servlet
  • SQL Tutorial
  • Core Java
  • Spring
  • JavaScript
  • Struts
  • RubyonRails

  • <

    Reactjs Forms

    React uses forms to allow users to interact with the web page.


    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(e) {
          this.setState({data: e.target.value});
       }
       render() {
          return (
             <div>
                <input type = "text" value = {this.state.data} 
                   onChange = {this.updateState} />
                <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.