Quotes help make search much faster. Example: "Practice Makes Perfect"

Tuesday, August 14, 2018

Codecademy Sample Solution: Use 'this' in a Component


// sample solution to app.js

import React from 'react';
import ReactDOM from 'react-dom';

class MyName extends React.Component {
// name property goes here:
  get name() {
    return 'Nate';
  }

  render() {
    return <h1>My name is {this.name}.</h1>;
  }
}

ReactDOM.render(<MyName />, document.getElementById('app'));

No comments:

Post a Comment


This is an example of scrolling text using Javascript.

Popular Posts