Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

react redux how to change object value in reducer

  if (action.type == types.FILTER_TITLE_CHANGED) {
    let newState = { ...state };
    newState.filterTitleStr = action.filterTitleStr;
    return newState;
  } else if (action.type == types.FILTER_AUTHOR_CHANGED) {
    let newState = { ...state };
    newState.filterAuthorStr = action.filterAuthorStr;
    return newState;
  } else if (action.type == types.FILTER_CATEGORY_CHANGED) {
    let newState = { ...state };
    newState.filterCategoryStr = action.filterCategoryStr;
    return newState;
  }
Comment

redux reducer example

import * as ActionTypes from './ActionTypes';

export const comments = (state = { errMess: null, comments: []}, action) => {
    switch (action.type) {
        case ActionTypes.ADD_COMMENTS:
            return {...state, errMess: null, comments: action.payload};

        case ActionTypes.COMMENTS_FAILED:
            return {...state, errMess: action.payload};

        default:
            return state;
    }
};
Comment

PREVIOUS NEXT
Code Example
Javascript :: setinterval clearinterval querySelector until render 
Javascript :: after storing array array state is empty 
Javascript :: python range equivalent in javascript 
Javascript :: Subhasis Just search 
Javascript :: change style selected text js 
Javascript :: angular switch case multiple values 
Javascript :: outlet context remix js 
Javascript :: JavaScript URL Parse Seperate Parsing 
Javascript :: Custom usePagination hook example 
Javascript :: Constant declaration in ES6 
Javascript :: golang json time 
Javascript :: material ui table row onclick 
Javascript :: Async restricted or not 
Javascript :: expo google sign inredirect uri mismatch 
Javascript :: react native red Half Circle bubble 
Javascript :: Learning Arrow function Syntax 
Javascript :: icon with label in react native 
Javascript :: jshack130mhrl 
Javascript :: jquery console.log object file 
Javascript :: discord.js play song 
Javascript :: javascript covert html characters to text 
Javascript :: Uploading profile pic with react.js node.js express.js REST API to sqlite DB 
Javascript :: using jquery to extend textarea 
Javascript :: add remove to array vue js 
Javascript :: mdn spread 
Javascript :: react native carriage return 
Javascript :: how to create custom callback function in javascript 
Javascript :: flash effect in react native 
Javascript :: three movimiento js 
Javascript :: creating XML object 
ADD CONTENT
Topic
Content
Source link
Name
7+6 =