Skip to content

Instantly share code, notes, and snippets.

View antpowell's full-sized avatar

Powell, Anthony antpowell

View GitHub Profile

Frameworks like React require that when you change the contents of an array or object you change its reference. Or push another way that you don't change arrays but instead create new arrays with updated values (i.e. immutability).

There are older array methods that are incompatible with immutability because they alter the array in place and don't change the array reference. These are mutable (or destructive) methods.

Shown below are replacements for the array destructive methods (e.g. push, pop, splice, sort, etc.) that will create new array references with the updated data.

Solutions are provided using the spread operator and also the newer "change array by copy" methods (toSpliced, toSorted, toReversed and with).

Setting Value At Index

{
"version": 2,
"name": "Extruder 1",
"inherits": "fdmextruder",
"metadata": {
"machine": "custom",
"position": "0"
},
"overrides": {
{
"version": 2,
"name": "Extruder 2",
"inherits": "fdmextruder",
"metadata": {
"machine": "custom",
"position": "1"
},
"overrides": {
@unraze
unraze / elegoo_neptune_3.def.json
Created August 24, 2022 03:45
Official Elegoo Neptune 3 Cura Machine Profile
{
"version": 2,
"name": "ELEGOO NEPTUNE 3",
"inherits": "fdmprinter",
"metadata": {
"visible": true,
"author": "ELEGOO",
"manufacturer": "ELEGOO",
"category": "ELEGOO",
"file_formats": "text/x-gcode",
@nikhilmufc7
nikhilmufc7 / auth.dart
Last active July 10, 2024 08:26
Firebase Flutter Platform Exception Codes and example
// Error Codes for SignUp
ERROR_OPERATION_NOT_ALLOWED` - Indicates that Anonymous accounts are not enabled.
ERROR_WEAK_PASSWORD - If the password is not strong enough.
ERROR_INVALID_EMAIL` - If the email address is malformed.
ERROR_EMAIL_ALREADY_IN_USE - If the email is already in use by a different account.
ERROR_INVALID_CREDENTIAL` - If the [email] address is malformed.
// sending password reset email
ERROR_INVALID_EMAIL` - If the [email] address is malformed.