DEV Community 👩‍💻👨‍💻

Helder B. Berto
Helder B. Berto

Posted on

🔥 Quick Tip: How to create a "PureComponent" as a functional way

On this simple trick, I'll show you how to create a PureComponent as a functional way with React.memo.

class Button extends React.PureComponent {
  render() {
    const { text } = this.props;
    return (
      <button type="button">{text}</button>


// With Function
function Button({ text }) {
  return <button type="button">{text}</button>;
export default React.memo(Button);

// With Arrow Function
const Button = React.memo(({ text }) => <button type="button">{text}</button>);
export default Button;
Enter fullscreen mode Exit fullscreen mode

Did you like it? Comment, share! ✨

Oldest comments (0)

🌚 Friends don't let friends browse without dark mode.

Just kidding, it's a personal preference. But you can change your theme, font, etc. in your settings.

The more you know. 🌈