Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

react-shallow-equal

Vlad-Zhukov4.9kMIT0.1.1

Efficient shallow equality algorithm for React and React Native

react, react-native, shallowequal, shallow-equal, shallowCompare, shallow-compare, equals, shouldComponentUpdate

readme

react-shallow-equal · npm

Efficient shallow equality algorithm for React and React Native.

This is a fork of lelandrichardson/shallow-element-equals.

Table of Contents

Install

yarn add react-shallow-equal
  # or
npm install --save react-shallow-equal

Usage

import React, {PureComponent} from 'react';
import {propsEqual} from 'react-shallow-equal';

// ...

shouldComponentUpdate(nextProps) {
  return !propsEqual(this.props, nextProps);
}

// ...

API

propsEqual(a, b, options)

elementsEqual(a, b)

stylesEqual(a, b)

See lelandrichardson/style-equal