Answers for "react with pure components"

1

react with pure components

Simple example of react pure component

import React from 'react';

class PercentageStat extends React.PureComponent {

  render() {
    const { label, score = 0, total = Math.max(1, score) } = this.props;

    return (
      <div>
        <h6>{ label }</h6>
        <span>{ Math.round(score / total * 100) }%</span>
      </div>
    )
  }
}
Posted by: Guest on February-06-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language