Loop through an array in JavaScript

Three main options: for (var i = 0; i < xs.length; i++) { console.log(xs[i]); } xs.forEach((x, i) => console.log(x)); for (const x of xs) { console.log(x); } Detailed examples are below. 1. Sequential for loop:  Run code snippet Pros Works on every environment You can use break and continue flow control statements Cons Too verbose Imperative Easy to have off-by-one errors (sometimes also … Read more

Invariant Violation: Objects are not valid as a React child

In my component’s render function I have: everything renders fine, however when clicking the <li> element I receive the following error: Uncaught Error: Invariant Violation: Objects are not valid as a React child (found: object with keys {dispatchConfig, dispatchMarker, nativeEvent, target, currentTarget, type, eventPhase, bubbles, cancelable, timeStamp, defaultPrevented, isTrusted, view, detail, screenX, screenY, clientX, clientY, … Read more

Invariant Violation: Objects are not valid as a React child

In my component’s render function I have: everything renders fine, however when clicking the <li> element I receive the following error: Uncaught Error: Invariant Violation: Objects are not valid as a React child (found: object with keys {dispatchConfig, dispatchMarker, nativeEvent, target, currentTarget, type, eventPhase, bubbles, cancelable, timeStamp, defaultPrevented, isTrusted, view, detail, screenX, screenY, clientX, clientY, … Read more

What is VanillaJS?

This is VanillaJS (unmodified): As you can see, it’s not really a framework or a library. It’s just a running gag for framework-loving bosses or people who think you NEED to use a JS framework. It means you just use whatever your (for you own sake: non-legacy) browser gives you (using Vanilla JS when working … Read more