September 2018
Beginner
156 pages
3h 28m
English
A React component is created by extending the Component class provided by React as follows:
import React, { Component } from 'react';import './button.css';export class Button extends Component { render() { return ( <button className={this.props.type}> {this.props.children} </button> ); }}
Here, the Button class extends React's Component class and overrides the render method. The render method returns the JSX, which will be rendered on the DOM when the page loads. The type and children properties are available in this.props. React allows you to pass data to its components through props and does so by using the following syntax:
import React, { Component } from 'react';import { Button } from './components/Button/button'; ...Read now
Unlock full access