Skip to content

Instantly share code, notes, and snippets.

View Jaredk3nt's full-sized avatar

Jared Jones Jaredk3nt

View GitHub Profile
{
"Ansi 3 Color" : {
"Red Component" : 1,
"Color Space" : "sRGB",
"Blue Component" : 0.38039215686274508,
"Alpha Component" : 1,
"Green Component" : 0.88627450980392153
},
"Tags" : [
@Jaredk3nt
Jaredk3nt / machine.js
Last active February 24, 2021 19:42
Generated by XState Viz: https://xstate.js.org/viz
const multiPitchMachine = Machine({
id: 'multi-pitch',
initial: 'idle',
context: {
pitches: 0
},
states: {
idle: {
on: {
@Jaredk3nt
Jaredk3nt / context-thunk.js
Last active November 9, 2024 13:08
React Context Thunk Pattern
const MyContext = createContext();
function reducer(state, action) {
switch (action.type) {
case "COUNT_REQUEST":
return {
...state,
loading: true,
err: undefined
};
@Jaredk3nt
Jaredk3nt / HttpContext.jsx
Created October 2, 2018 19:46
Http handler written using Reacts context API
const DEFAULT = {
data: [],
isLoading: false
}
const { Provider, Consumer } = React.createContext({ ...DEFAULT });
class HttpProvider extends Component {
state = { ...DEFAULT };
@Jaredk3nt
Jaredk3nt / HttpProvider.jsx
Last active October 2, 2018 20:16
A simple HOC for handling http requests
class HttpProvider extends Component {
state = {
isLoading: false,
data: []
}
// Fetch initial data on mount
async componentDidMount() {
await this.updateData();
}
// HOF for adding loading to async function
@Jaredk3nt
Jaredk3nt / plain-jane-react.html
Created August 2, 2018 02:49
Did you know you can write react without the overhead and boilerplate of tools like CRA? If you are writing a quick application heres a single file html document that lets you get up and running with React fast and even allows you to use es6 and JSX!
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Plain Jane React App</title>
</head>
<body>