How to use the react-redux/lib/utils/shallowEqual function in react-redux

To help you get started, we’ve selected a few react-redux examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github tonyhb / redux-ui / test / ui / context.js View on Github external
it('parent component only gets its own context', () => {
      const p = renderAndFind(UIChildWithOwnStateJSX, Parent);
      assert(shallowEqual(p.props.ui, uiState), 'parent only has its own context and not childrens');
    });
github tonyhb / redux-ui / test / ui / context.js View on Github external
it('child merges parent UI context with its own UI context', () => {
      const child = renderAndFind(UIChildWithOwnStateJSX, Child);
      const expectedState = {
        name: 'parent',
        child: true
      };
      assert(shallowEqual(child.props.ui, expectedState), 'child merges context');
    });
github tonyhb / redux-ui / test / ui / context.js View on Github external
it('components with the same key and nesting share the same context', () => {
        const tree = render(<div></div>);
        const a = ReactTestUtils.findRenderedComponentWithType(tree, Foo);
        const b = ReactTestUtils.findRenderedComponentWithType(tree, Bar);

        assert(shallowEqual(a.props.ui, b.props.ui));
        a.updateContext();
        assert(a.props.ui.name === 'misc');
        assert(shallowEqual(a.props.ui, b.props.ui));
    });
github davidkpiano / react-redux-form / src / utils / sequence.js View on Github external
const dispatchValidate = value => {
      const fieldValidity = getValidity(props.validators, value);
      const fieldErrors = getValidity(props.errors, value);

      const errors = props.validators
        ? merge(invertValidity(fieldValidity), fieldErrors)
        : fieldErrors;

      if (fieldValue && !shallowEqual(errors, fieldValue.errors)) {
        dispatch(setErrors(model, errors));
      }

      return value;
    };
github webkom / lego-webapp / app / utils / fetchOnUpdate.js View on Github external
componentWillReceiveProps(nextProps: Props) {
        const params = extractWatchedProps(watchProps, this.props);
        const nextParams = extractWatchedProps(watchProps, nextProps);

        if (!shallowEqual(params, nextParams)) {
          this.fetchData(nextParams, nextProps);
        }
      }
github emmenko / redux-react-router-async-example / lib / decorators / fetchOnUpdate.js View on Github external
componentDidUpdate (prevProps) {
      const params = mapParams(paramKeys, this.props.params)
      const prevParams = mapParams(paramKeys, prevProps.params)

      if (!shallowEqual(params, prevParams))
        fn(params, this.props.actions)
    }
github emmenko / redux-react-router-async-example / lib / components / github / Explore.js View on Github external
componentWillReceiveProps (nextProps) {
    if (!shallowEqual(this.props.params, nextProps.params))
      this.setState({
        usernameOrRepo: parseFullName(nextProps.params)
      })
  }
github tonyhb / autoaction / src / autoaction.js View on Github external
shouldComponentUpdate(nextProps, nextState) {
        return !shallowEqual(nextProps, this.props);
      }