Nozzle Piping Mismatch

    props-changed

    2.2.0 • Public • Published

    props-changed

    Shallow equals compare if specified properties of two objects are different.

    Usage

    propsChanged(propNames, objectA, objectB);

    Parameters

    • propNames array of properties to check
    • objectA and objectB objects to compare

    Return value

    true if any of the values at each property name are different, else false.

    Examples

    import propsChanged from 'props-changed';
    
    propsChanged(['x'], { x: 1, y: 1 }, { x: 1, y: 2 });
    // returns false
    
    propsChanged(['x', 'y'], { x: 1, y: 1 }, { x: 1, y: 2 });
    // returns true

    Also works well with React components

    import propsChanged from 'props-changed';
    import React from 'react';
    
    class MyComponent extends React.Component {
      
      shouldComponentUpdate(nextProps) {
        return propsChanged(['x', 'y'], this.props, nextProps);
      }
      
    };

    Install

    npm i props-changed

    DownloadsWeekly Downloads

    7

    Version

    2.2.0

    License

    MIT

    Unpacked Size

    8.72 kB

    Total Files

    8

    Last publish

    Collaborators

    • jacobbuck