0

creating class component with ES5 would be like this

var someClass = React.createClass({});

and rendering it using

ReactDOM.render(<someClass/>, elementSelector);

creating class component with ES6 somehow be like this

class someAnotherClass extends React.Component{
     constructor(){
          super();
     }
     render(){}
}

how do we render with ES6?

1

1 Answer 1

2

Step 1: create Component-

///dashboard.js
import React from 'react';
class Dashboard extends React.Component {    
   render() {
      return (
         <div>
            Dash board
         </div>
      );
   }
}

export default Dashboard;

Step 2: mount it to DOM as-

//index.js
import {render} from 'react-dom';
import Dashboard from './dashboard';

render(<Dashboard/>, document.getElementById('target');
Sign up to request clarification or add additional context in comments.

1 Comment

So you are saying... in exactly the same way? Or what are you trying to say with that answer?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.