no-reducer
  • πŸš€Introduction
    • ☺️Demonstration
  • πŸ–₯️Installation
  • πŸ“–No-Reducer Actions
    • 🎯destination path
    • create
      • create an object/array
    • insert
      • insert to an array item
    • remove
      • remove with condition
      • remove without condition
    • replace
      • replace with condition
      • replace without condition
    • update
      • update with condition
    • append
    • clear
      • clear an array item
Powered by GitBook
On this page
  1. No-Reducer Actions

create

Previousdestination pathNextcreate an object/array

Last updated 2 years ago

This function is used to create an object or an array inside of the root of states.

Each object has a unique name; if there is a duplicated name, the object's value will be overridden.

Create an object

dispatch(create('YOUR-OBJECT-NAME', { YOUR: 'OBJECT' }));

Create an array

dispatch(create('YOUR-ARRAY-NAME', ['YOUR', 'ARRAY' ]));

Example I want to create an object named User from

import { create } from "no-reducer";
...
const response = await axios.get('https://jsonplaceholder.typicode.com/users/2');
await dispatch(create('User', response.data));
πŸ“–
https://jsonplaceholder.typicode.com/users/2