How to use the react-addons-update.default function in react-addons-update

To help you get started, we’ve selected a few react-addons-update 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 tomchentw / react-google-maps / examples / simplemap / scripts / ReactRoot.js View on Github external
setTimeout(() => {
      var {markers} = this.state;
      markers = update(markers, {
        $push: [
          {
            position: {
              lat: 25.99,
              lng: 122.9,
            },
            defaultAnimation: 2,
            key: Date.now(),// Add a key property for: http://fb.me/react-warning-keys
          },
        ],
      });
      this.setState({ markers });
    }, 2000);
  }
github dustingetz / react-cursor / src / update.js View on Github external
rootSwap(function (rootVal) {
    var nextRootVal;

    if (path.length > 0) {
      nextRootVal = persistentUpdate(
          rootVal,
          path.concat(operation).reduceRight(
              unDeref,
              leafUpdate(getRefAtPath(rootVal, path))
          )
      );
    } else if (path.length === 0) {
      nextRootVal = leafUpdate(rootVal);
    }

    // would be better to do this valEq check on just the leaf
    return valEq(rootVal, nextRootVal)
        ? rootVal // preserve === if same value
        : nextRootVal;
  });
}
github dustingetz / update-in / src / update-in.js View on Github external
export function updateIn (rootVal, paths, f, ...args) {
  let ff = (v) => f.apply(null, [v].concat(args));

  var newRootVal;
  if (paths.length > 0) {
    const command = rootAt(paths, {$apply: ff});
    newRootVal = persistentUpdate(rootVal, command);
  }
  else if (paths.length === 0) {
    newRootVal = ff(rootVal);
  }

  // would be better to do this valEq check on just the leaf
  return isEqual(rootVal, newRootVal)
      ? rootVal // preserve === if same value
      : newRootVal;
}
github tomchentw / react-google-maps / examples / simplemap / scripts / ReactRoot.js View on Github external
_handle_map_click (event) {
    var {markers} = this.state;
    markers = update(markers, {
      $push: [
        {
          position: event.latLng,
          defaultAnimation: 2,
          key: Date.now(),// Add a key property for: http://fb.me/react-warning-keys
        },
      ],
    });
    this.setState({ markers });
  }
github dustingetz / update-in / src / update-in.js View on Github external
export function unshift (as, bs) {
  return persistentUpdate(as, {$unshift: bs});
}
github tomchentw / react-google-maps / examples / gh-pages / src / pages / AsyncGettingStarted.js View on Github external
handleMarkerRightclick(index, event) {
    /*
     * All you modify is data, and the view is driven by data.
     * This is so called data-driven-development. (And yes, it's now in
     * web front end and even with google maps API.)
     */
    let { markers } = this.state;
    markers = update(markers, {
      $splice: [
        [index, 1],
      ],
    });
    this.setState({ markers });
  }
github dustingetz / update-in / src / update-in.js View on Github external
export function merge (a, b) {
  return persistentUpdate(a, {$merge: b});
}
github tomchentw / react-google-maps / examples / gh-pages / src / pages / GeojsonToComponents.js View on Github external
handleMapZoomChanged() {
    this.setState(update(this.state, {
      geoStateBy: {
        0: {
          $merge: {
            zoom: this.refs.map.getZoom(),
          },
        },
        1: {
          $merge: {
            opacity: 0.2 + (this.refs.map.getZoom() / 14),
          },
        },
      },
    }));
  }
github dustingetz / update-in / src / update-in.js View on Github external
export function push (as, bs) {
  return persistentUpdate(as, {$push: bs});
}
github tomchentw / react-google-maps / examples / gh-pages / src / pages / GeojsonToComponents.js View on Github external
handleMarkerClick() {
    this.setState(update(this.state, {
      geoStateBy: {
        0: {
          $merge: {
            zoom: 1 + this.refs.map.getZoom(),
          },
        },
      },
    }));
  }

react-addons-update

>**Note:** >This is a legacy React addon, and is no longer maintained. > >We don't encourage using it in new code, but it exists for backwards compatibility. >The recommended migration path is to use [`immutability-helper`](https://github.com/kolodny/im

MIT
Latest version published 3 years ago

Package Health Score

78 / 100
Full package analysis

Popular react-addons-update functions