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 :: toLocalString 
Javascript :: js iife 
Javascript :: javascript round 
Javascript :: sequelize select fields 
Javascript :: plotly express bar graph 
Javascript :: sum range javascript 
Javascript :: discord.js create permanent invite 
Javascript :: Square star pattern in JavaScript 
Javascript :: try catch javascript 
Javascript :: jquery var_dump array 
Javascript :: assign input text value jquery 
Javascript :: extended class call method from super in javascript 
Javascript :: combine the values of 2 arrays in key = value jquery 
Javascript :: import everything javascript 
Javascript :: how do you swap the vaRIables js 
Javascript :: js date in arabic 
Javascript :: display for sometime only session flash message in laravel with javascript 
Javascript :: jquery append after number of chars in string 
Javascript :: jspdf reduce size file 
Javascript :: Run project in visual studio with iis express 
Javascript :: define value in js 
Javascript :: javascript array from string 
Javascript :: heroku buildpacks with react 
Javascript :: dynamic set required in angular using formcontrol 
Javascript :: select id get option value jquery 
Javascript :: how to get the last two characters of a string in javascript 
Javascript :: javascript array to string without commas 
Javascript :: download datepicker js 
Javascript :: change version webpack-dev-middleware 
Javascript :: cors axios 
ADD CONTENT
Topic
Content
Source link
Name
6+8 =