Skip to content

Instantly share code, notes, and snippets.

View markerikson's full-sized avatar

Mark Erikson markerikson

View GitHub Profile
@markerikson
markerikson / job-search-questions.md
Last active May 7, 2024 14:10
Assorted questions to ask companies in interviews

Questions

Company

  • company location / remote?
  • what project management method?
  • good and bad company culture?
  • performance reviews?
  • what's the path to profitability?
@markerikson
markerikson / chatsSlice.ts
Last active May 2, 2024 01:27
Nested `createEntityAdapter` example
// Example of using multiple / nested `createEntityAdapter` calls within a single Redux Toolkit slice
interface Message {
id: string;
roomId: string;
text: string;
timestamp: string;
username: string;
}
@markerikson
markerikson / redux-socket-middleware-example.js
Created June 28, 2018 00:37
Redux socket middleware example usage
const createMySocketMiddleware = (url) => {
return storeAPI => {
let socket = createMyWebsocket(url);
socket.on("message", (message) => {
storeAPI.dispatch({
type : "SOCKET_MESSAGE_RECEIVED",
payload : message
});
});
@markerikson
markerikson / connectExample.js
Last active March 5, 2024 01:24
React-Redux connect example
import {action1, action2} from "myActions";
import {bindActionCreators} from "redux";
import {connect} from "react-redux";
const mapStateToProps = (state, ownProps) = {
return {
counter : state.counter,
someComponentValue : state.things[ownProps.someIdProp]
};
}
@markerikson
markerikson / lwj-redux-2024.md
Created January 4, 2024 16:24
Learn with Jason, 2024-01-04 - What's New in Redux Toolkit 2.0?
@markerikson
markerikson / render-logic.js
Last active January 1, 2024 06:20
React render function organization
// See https://blog.isquaredsoftware.com/presentations/react-redux-ts-intro-2020-12/#/36 for slides
// My basic render function structure:
function RenderLogicExample({
someBoolean, // 1) Destructure values from `props` object
someList,
}) {
// 2) Declare state values
const [a, setA] = useState(0);
const [b, setB] = useState(0);
@markerikson
markerikson / cheng-lou-spectrum-of-abstraction.md
Last active October 23, 2023 23:18
Cheng Lou - "On the Spectrum of Abstraction" summarized transcript (React Europe 2016)

Cheng Lou - On the Spectrum of Abstraction

Cheng Lou, a former member of the React team, gave an incredible talk at React Europe 2016 entitled "On the Spectrum of Abstraction". That talk is available for viewing here: https://www.youtube.com/watch?v=mVVNJKv9esE

It's only a half-hour, but it is mind-blowing. It's worth re-watching two or three times, to let the ideas sink in.

I just rewatched the talk for some research, and wrote down a summary that's semi-transcript-ish. I didn't see any other transcripts for this talk, other than the auto-generated closed captions, so I wanted to share for reference.

Summary

@markerikson
markerikson / react-redux-stale-props-subscriptions.md
Created April 16, 2019 03:29
Reactiflux chat log: React-Redux, "stale props", and subscriptions

[9:13 PM] harry : @acemarke are people still going to need to add Connect components to their jsx to use a redux hook? i couldnt tell where that ended up
[9:13 PM] harry : didnt 100% grok the whole thing
[9:13 PM] acemarke : awright, lemme recap the issue
[9:13 PM] acemarke : :)
[9:13 PM] harry : sweet
[9:13 PM] acemarke : from the top
[9:13 PM] harry : i kinda got the gist of the zombie child thing too. not sure how a child actually subscribes before a parent, though
[9:14 PM] acemarke : (drat... I can already tell this is gonna be one of those chats I have to export to a gist because I'm about to write a lot)
[9:15 PM] acemarke : up through v4, there was a potential bug due to the timing of store subscriptions
[9:15 PM] acemarke : wrapper components subscribe in componentDidMount, which fires bottom-up

@markerikson
markerikson / rtk-esm-ts-notes-2023-02-27.md
Last active September 3, 2023 00:33
RTK ESM/TS Config meeting notes - 2023-02-27/28

RTK ESM/TS Discussion

Attendees:

  • Nathan Bierema
  • Mateusz Burzynski
  • Mark Erikson

Notes

  • Mateusz: what do you want besides "ship widely compat code?" What preferences?
@markerikson
markerikson / AppErrorFallback.tsx
Created July 1, 2021 13:43
Next.js ErrorBoundary example
import React from 'react';
import Jumbotron from 'react-bootstrap/Jumbotron';
import Alert from 'react-bootstrap/Alert';
import Button from 'react-bootstrap/Button';
import { FallbackProps } from 'react-error-boundary';
interface AEFProps extends FallbackProps {