Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

console redux state shows proxy

import { current } from '@reduxjs/toolkit'

const todosSlice = createSlice({
  name: 'todos',
  initialState: todosAdapter.getInitialState(),
  reducers: {
    todoToggled(state, action) {
      // ❌ ERROR: logs the Proxy-wrapped data
      console.log(state)
      // ✅ CORRECT: logs a plain JS copy of the current data
      console.log(current(state))
    },
  },
})
Comment

redux state proxy

console.log(current(state))
Comment

redux state proxy

Redux toolkit includes the immer current function specifically for this purpose. You can call:

console.log(current(state))
Comment

PREVIOUS NEXT
Code Example
Javascript :: how to find length of string in javascript without using length method 
Javascript :: react material ui media queries 
Javascript :: js regex i modifier 
Javascript :: how to wait in javascript 
Javascript :: datatable after loading function 
Javascript :: ajax call too functions.php 
Javascript :: express js cors 
Javascript :: change event listener in javascript 
Javascript :: js check which number is larger 
Javascript :: jquery read href attribute 
Javascript :: react native regenerate android and ios folders 
Javascript :: Regex match word js 
Javascript :: jquery observe class change 
Javascript :: jquery scroll to div with offset 
Javascript :: react native apk build 
Javascript :: javascript remove duplicate in two arrays 
Javascript :: angular add object to array 
Javascript :: p5.js change button position 
Javascript :: append sibling javascript after first child 
Javascript :: angular 8 to 9 
Javascript :: how to get clicked element class in jquery 
Javascript :: are you sure you want to proceed click ok button javascript code 
Javascript :: react typewriter 
Javascript :: val select jquery 
Javascript :: eslint ignore file rule 
Javascript :: style before javascript 
Javascript :: scrollto jquery 
Javascript :: link to another page and achor 
Javascript :: check if number is single digit javascript 
Javascript :: ffmpeg convert mp4 to avi 
ADD CONTENT
Topic
Content
Source link
Name
7+7 =