How to use the immer.default function in immer

To help you get started, we’ve selected a few immer 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 linq2js / immhelper / dist / benchmarks.js View on Github external
setIn: function setIn(obj, path, val) {
      return immer(obj, function (x) {
        x = path.slice(0, path.length - 1).reduce(function (x, path) {
          return x[path];
        }, x);
        x[path[path.length - 1]] = val;
      });
    },
    merge: function merge(obj1, obj2) {
github linq2js / immhelper / dist / benchmarks.js View on Github external
setAt: function setAt(arr, idx, val) {
      return immer(arr, function (x) {
        x[idx] = val;
      });
    },
    getAtDeep: function getAtDeep(arr, idx1, idx2) {
github linq2js / immhelper / benchmarks.js View on Github external
setAtDeep: function(arr, idx1, idx2, val) {
      return immer(arr, x => {
        x[idx1][idx2] = val;
      });
    }
  };
github hex13 / enter-ghost / packages / transmutable / benchmark.js View on Github external
benchmark(() => {
    return immer(original, transformer);
}, 'immer without autofreeze - array');
github linq2js / immhelper / benchmarks2.js View on Github external
setAtDeep: function(arr, idx1, idx2, val) {
      return immer(arr, x => {
        x[idx1][idx2] = val;
      });
    }
  };
github kamilkisiela / graphql-inspector / scripts / release.js View on Github external
function updateJSON(filepath, updateFn) {
  const content = readFileSync(filepath, {encoding: 'utf-8'});
  const {indent} = detectIndent(content);
  const data = JSON.parse(content);

  const modified = immer(data, updateFn);

  writeFileSync(filepath, JSON.stringify(modified, null, indent), {
    encoding: 'utf-8',
  });
}
github immerjs / use-immer / index.js View on Github external
  reducer = React.useMemo(() => produce(reducer), [produce, reducer]);
  return React.useReducer(reducer, initialState, initialAction);
github jamiebuilds / bey / src / bey.js View on Github external
function update(target, updater) {
  let currState = target.get();
  let nextState = immer(currState, updater);
  if (nextState !== currState) target.set(nextState);
}
github linq2js / immhelper / dist / benchmarks2.js View on Github external
setAtDeep: function setAtDeep(arr, idx1, idx2, val) {
      return immer(arr, function (x) {
        x[idx1][idx2] = val;
      });
    }
  };
github byte-fe / react-model / dist / index.js View on Github external
var setPartialState = function (name, partialState) {
    if (partialState === void 0) { partialState = {}; }
    if (typeof partialState === 'function') {
        var state_1 = GlobalState[name].state;
        state_1 = immer_1["default"](state_1, partialState);
        GlobalState = immer_1["default"](GlobalState, function (s) {
            s[name].state = state_1;
        });
    }
    else {
        GlobalState = immer_1["default"](GlobalState, function (s) {
            s[name].state = __assign({}, s[name].state, partialState);
        });
    }
    return GlobalState;
};
var getState = function (modelName) {

immer

Create your next immutable state by mutating the current one

MIT
Latest version published 7 months ago

Package Health Score

93 / 100
Full package analysis