How to use react-addons-update - 10 common examples

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 edwardfhsiao / react-picky-date-time / src / js / PickyDateTime / Clock / index.js View on Github external
// debugger;
    if (!isNaN(newValue) && refName != 'meridiem') {
      let newDegree;
      if (refName == 'clockHandSecond') {
        newDegree = Number(newValue) * SECOND_DEGREE_NUMBER;
      }
      if (refName == 'clockHandMinute') {
        newDegree = Number(newValue) * MINUTE_DEGREE_NUMBER;
      }
      if (refName == 'clockHandHour') {
        if (Number(newValue) == 0) {
          newValue = 12;
        }
        newDegree = Number(newValue) * HOUR_DEGREE_NUMBER;
      }
      elObj = update(elObj, {
        value: { $set: newValue },
        degree: { $set: newDegree },
        startAngle: { $set: newDegree },
        angle: { $set: newDegree }
      });
      this.setState({ [refName]: elObj, slectionRange });
    }

    if (key == 'ArrowUp' || key == 'ArrowDown') {
      if (refName == 'meridiem') {
        let meridiem = 'AM';
        if (elObj == 'AM') {
          meridiem = 'PM';
        }
        elObj = meridiem;
        this.setState({ [refName]: elObj, slectionRange });
github pdaddyo / soundbounce-v2 / src / redux / modules / spotify.js View on Github external
const mergeTracks = ({state, tracks}) => {
	let existingTracks = state.tracks;
	const updateCommand = {};
	// don't want to overwrite tracks if already have more info
	for (let track of tracks) {
		if (existingTracks[track.id]) {
			track = {...existingTracks[track.id], ...track};
		}
		updateCommand[track.id] = {$set: track};
	}
	return {
		...state,
		tracks: update(state.tracks, updateCommand)
	};
};
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 node-vision / node-react-xero-app / app / components / InvoiceUpdate.jsx View on Github external
addItem() {
    let newState = reactUpdate(this.state, {
      invoice: {
        items: {
          $push: [this.newItem]
        }
      },
      openDialogStandardActions: {$set: false}
    });

    this.setState(newState);

    this.newItem = {};
  }
github getheimdall / heimdall / heimdall-frontend / src / components / apis / SingleResource.js View on Github external
handleOperationPath(e) {
        const newState = update(this.state, { newOperation: {path: {$set: e.target.value}} })
        this.setState(newState)
    }
github leozdgao / taskbox / src / components / ScrollPanel / ScrollPanel.jsx View on Github external
_showScrollY () {
    this.setState({
      scrollYStyles: update(this.state.scrollYStyles, {
        display: { $set: 'block' },
        height: { $set: this._getScrollYHeight() }
      })
    })
  }
github appirio-tech / connect-app / src / projects / reducers / project.js View on Github external
function updateProductInPhases(phases, phaseId, productId, updateProduct, shouldReplace) {
  const phaseIdx = _.findIndex(phases, { id: phaseId })
  const productIdx = _.findIndex(phases[phaseIdx].products, { id: productId })

  const updatedProduct = shouldReplace ? updateProduct : update(
    phases[phaseIdx].products[productIdx],
    updateProduct
  )

  const updatedPhase = update(phases[phaseIdx], {
    products: { $splice: [[productIdx, 1, updatedProduct]] }
  })

  return update(phases, { $splice : [[phaseIdx, 1, updatedPhase]] })
}

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