JavaScript

2013 readers
1 users here now

founded 1 year ago
MODERATORS
126
 
 

Am I the only one that feels kinda lost trying to debug things in Redux?

Maybe I got spoiled with Nuxt, maybe I need different browser tools, maybe I need to take a redux/reselect course to remind myself wtf is going on over here...

but I feel like even simple things like seeing a components props or the app state is difficult to do in browser inspector, even with the usual react browser extension.

I don't know what I'm hoping for here ... maybe a youtube video recommendation or a browser extension or a tiny violin. Either way this seemed like the best community on Lemmy to ask.

127
128
129
130
 
 

Answer: create a new object with the properties of the two original objects using the spread operator.

The order you insert the objects into the new merged object determines which object's properties take priority over the other.

Linked example:

const obj1 = { foo: "bar", x: 42 };
const obj2 = { foo: "baz", y: 13 };

const clonedObj = { ...obj1 };
// { foo: "bar", x: 42 }

const mergedObj = { ...obj1, ...obj2 };
// { foo: "baz", x: 42, y: 13 }

You can find more discussion here: https://stackoverflow.com/questions/171251/how-can-i-merge-properties-of-two-javascript-objects-dynamically

131
 
 

If you're like myself and forget over time what some of the more uncommonly used equality operators actually do under the hood, this resource is great for getting a quick explanation of the functionality and a general level of support across browsers.

Simply type in the operator you'd like an explanation for such as the nullish-coalescing operator (??) to get an immediate result. You can also select an operator from the list under the search if you're not immediately sure which operator you're looking for.

132
 
 

Svelte 4.0 Beta is out. The most important changes are the minimum requirement of Node 16, TypeScript 5 and Webpack 5 (although the use of Webpack is not recommended)

Svelte 4.0 focusses on structural improvements of the project and comes with better types for use in TypeScript. Even though the project, itself, is now moving to JSDoc (they say that this makes library development a lot faster). More impactful changes are expected in Svelte 5.

133
 
 

A great write-up about optimizing a set of functions spread across a handful of popular JS libraries in a reasonably straightforward way to understand and replicate in the packages you know and use on a daily basis.