Questions related to redux and es6

let patentListDefault={
    list:[],
    count:0,
    isLoading: false,
}
export const patentDatas = (state=patentListDefault, action = {}) => {
    let imuDataList;
    let imuItem;
    switch(action.type){
        case "SAVEPATENTLIST":
            if(action.pageNo!=1){
                action.list=[...state.list,...action.list]
            }
            return {...state, ...action};
        default:
            return state;
    }
}

where return {.state, .action}; what does mean? what is the use of two extension operators in an object and concatenated with a comma?

Apr.01,2021

you can understand that both state and action are structured into a new object, realizing the function of object merging. Note that it is shallow copy . It has to be said that this feature is super easy to use


.

after reading this example, you should understand

var a = {name: 'a', age: '3'};
var b = {skill: 'swim'};
var c = {...a, ...b};
console.log(c);
// {name: "a", age: "3", skill: "swim"}

the first thing to say is return {.state, .action}; is not deconstruction.

this is called Spread syntax. He has a lot of uses!

Let's start with an example of an array:

function sum(x, y, z) {
  return x + y + z;
}

const numbers = [1, 2, 3];

console.log(sum(...numbers));
// expected output: 6

console.log(sum.apply(null, numbers));
// expected output: 6

Let's give another object example:

var obj1 = { foo: 'bar', x: 42 };
var obj2 = { foo: 'baz', y: 13 };
const merge = ( ...objects ) => ( { ...objects } );

var mergedObj = merge ( obj1, obj2);
// Object { 0: { foo: 'bar', x: 42 }, 1: { foo: 'baz', y: 13 } }

var mergedObj = merge ( {}, obj1, obj2);
// Object { 0: {}, 1: { foo: 'bar', x: 42 }, 2: { foo: 'baz', y: 13 } }

what you are talking about is actually an example of this object.

if you still don't understand, you can think of it as Object.assign ({}, state, action);

).
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1bee3db-39f9c.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1bee3db-39f9c.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?