• Core Java
  • Servlet
  • JSP
  • Java IO
  • RubyonRails
  • PHP
  • Struts
  • jQuery
  • Spring

  • <

    Reactjs Props

    React Props are like function arguments in JavaScript and attributes in HTML.To send props into a component, use the same syntax as HTML attributes:

    When we need immutable data in our component, we can just add props to reactDOM.render() function in main.js and use it inside our component.

    Example



    app.jsx
    
    import React from 'react';
    
    class App extends React.Component {
       render() {
          return (
             <div>
                <h1>{this.props.headerProp}</h1>
                <h2>{this.props.contentProp}</h2>
             </div>
          );
       }
    }
    export default App;
    

    main.js
    
    
    import React from 'react';
    import ReactDOM from 'react-dom';
    import App from './App.jsx';
    
    ReactDOM.render(<App headerProp = "Header..." contentProp = "prop content"/>, document.getElementById('app'));
    
    export default App;
    
    
















    © copyright 2017-2021 Completedone pvt ltd.