Registry / testing / react-addons-update

react-addons-update

JSON →
library15.6.3jsnpmunverified

A legacy React addon providing a simple immutability helper, `update()`, for updating nested objects and arrays in an immutable fashion using MongoDB-like query syntax. Version 15.6.3 is the last release; it is no longer maintained and is deprecated. Recommended replacement is `immutability-helper` v1.0.0+ (drop-in). The library is ESM and CJS compatible. Key differentiator: syntactic sugar over manual shallow copying with `$set`, `$push`, `$splice`, etc. Not recommended for new code due to deprecation.

npm install react-addons-update
INSTALL
IMPORT
SIG · REACT-ADDONS-UPDAT
R
react-addons-update
testingjavascriptv15.6.3
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

update
import update from 'react-addons-update'
import { update } from 'react-addons-update'
Default export only; named import will result in undefined.
update
var update = require('react-addons-update')
var update = require('react-addons-update').default
CommonJS: the package exports the function directly, not via .default.
update
const update = React.addons.update
const update = React.addons.updates
When using script tag, it's available as React.addons.update after React script.

Shows how to use update() to immutably set a nested value and push to an array, with result logging.

import update from 'react-addons-update'; const myData = { x: { y: { z: 5 } }, a: { b: [1, 2, 3] } }; const newData = update(myData, { x: { y: { z: { $set: 7 } } }, a: { b: { $push: [4] } } }); console.log(newData); // { x: { y: { z: 7 } }, a: { b: [1, 2, 3, 4] } } console.log(newData === myData); // false (shallow copy) console.log(newData.a === myData.a); // false (b array is new) console.log(newData.x.y === myData.x.y); // false (y object is new)
Debug
Known issues
deprecatedThis package is deprecated and no longer maintained. Use immutability-helper instead.
fix
npm install immutability-helper and replace imports with import update from 'immutability-helper'
affects: >=0.0.0
gotchaThe `$set` command replaces the entire target; to update a nested field, you must specify the full path.
fix
Always provide the complete path to the target field, e.g., update(obj, {a: {b: {$set: 3}}})
affects: >=0.0.0
gotchaThe `$splice` command expects an array of arrays, not a single array. Each inner array is passed as arguments to Array.prototype.splice.
fix
Use $splice: [[index, deleteCount, ...items]] instead of $splice: [index, deleteCount, ...items]
affects: >=0.0.0
gotchaThe `$merge` command only works on objects, not arrays, and does a shallow merge.
fix
Ensure the target is an object, and use $set for fine-grained control.
affects: >=0.0.0
breakingReact v15 addons like react-addons-update are not compatible with React v16+ if using the script tag approach (React.addons.update removed).
fix
Use npm import/require instead of script tag; upgrade to immutability-helper.
affects: >=0.0.0
Errors
Common errors & fixes
TypeError: update is not a function
Importing as named export instead of default export in ESM.
fix
Use import update from 'react-addons-update' (no curly braces).
Error: Invariant failed: update(): You provided an invalid spec...
Invalid command or missing $ prefix in the spec object.
fix
Ensure all command keys start with '$' (e.g., $set, $push).
Warning: update(): You are using a deprecated React addon. Use immutability-helper instead.
Using the deprecated package; the warning is emitted in newer versions or via runtime detection.
fix
Switch to immutability-helper for continued support.
TypeError: Cannot read property 'push' of undefined
Trying to $push into a property that doesn't exist or is not an array.
fix
Ensure the target path exists and ends with an array; initialize empty array if needed.
Error: update(): The target variable must be an object or array.
Passing a primitive (string, number) as the first argument.
fix
Only use update() on objects or arrays; for primitives assign directly.
Upgrade
Version history
15.6.3latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
25 hits · last 30 days
node
24
OpenAI (training)
1
Resources
react-addons-update — npm install react-addons-update · libregistry