Skip to content

Instantly share code, notes, and snippets.

@agenthunt
agenthunt / machine.js
Last active April 8, 2020 10:35
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@agenthunt
agenthunt / decoupled-routing-productsStateManager.js
Created August 11, 2019 17:06
decoupled-routing-productsStateManager.js
import { all, call, fork, put, take } from "redux-saga/effects";
export const types = {
GET_PRODUCTS_REQUEST: "@products/GET_PRODUCTS_REQUEST",
GET_PRODUCTS_PROGRESS: "@products/GET_PRODUCTS_PROGRESS",
GET_PRODUCTS_SUCCESS: "@products/GET_PRODUCTS_SUCCESS",
GET_PRODUCTS_FAILURE: "@products/GET_PRODUCTS_FAILURE",
};
export const actions = {
@agenthunt
agenthunt / hello-react-native-custom-renderer-myReactNativeYueRenderer.js
Created June 26, 2018 13:07
hello-react-native-custom-renderer-myReactNativeYueRenderer.js
import ReactReconciler from 'react-reconciler';
import gui from 'gui';
function traceWrap(hostConfig) {
let traceWrappedHostConfig = {};
Object.keys(hostConfig).map(key => {
const func = hostConfig[key];
traceWrappedHostConfig[key] = (...args) => {
console.trace(key);
return func(...args);
@agenthunt
agenthunt / hello-react-custom-renderer-myCustomRenderer.js
Created June 20, 2018 20:24
hello-react-custom-renderer-myCustomRenderer.js
import ReactReconciler from 'react-reconciler';
function traceWrap(hostConfig) {
let traceWrappedHostConfig = {};
Object.keys(hostConfig).map(key => {
const func = hostConfig[key];
traceWrappedHostConfig[key] = (...args) => {
console.trace(key);
return func(...args);
};
@agenthunt
agenthunt / hello-react-native-custom-renderer-myReactNativeWebRenderer.js
Last active June 26, 2018 13:05
hello-react-native-custom-renderer-myReactNativeWebRenderer.js
import ReactReconciler from 'react-reconciler';
function traceWrap(hostConfig) {
let traceWrappedHostConfig = {};
Object.keys(hostConfig).map(key => {
const func = hostConfig[key];
traceWrappedHostConfig[key] = (...args) => {
console.trace(key);
return func(...args);
};
@agenthunt
agenthunt / hello-react-native-custom-renderer-view.js
Last active June 21, 2018 11:49
hello-react-native-custom-renderer-view.js
import React, { Component } from 'react';
class View extends Component {
render() {
return (
<view
style={{
display: 'flex',
flexDirection: 'column',
...this.props.style
@agenthunt
agenthunt / hello-react-native-custom-renderer-myReactNativeWebRenderer-createInstance.js
Last active June 21, 2018 12:07
hello-react-native-custom-renderer-myReactNativeWebRenderer-createInstance.js
createInstance: (type, newProps, rootContainerInstance, _currentHostContext, workInProgress) => {
const domElement = document.createElement('div');
Object.keys(newProps).forEach(propName => {
const propValue = newProps[propName];
if (propName === 'children') {
if (type !== 'text') {
if (typeof propValue === 'string' || typeof propValue === 'number') {
throw new Error('Text strings must be rendered within a <Text> component.');
}
@agenthunt
agenthunt / hello-react-native-custom-renderer-app.js
Last active June 26, 2018 13:08
hello-react-native-custom-renderer-app.js
import React, { Component } from 'react';
import View from './view';
import Text from './text';
class App extends Component {
render() {
return (
<View
style={{
flex: 1,
@agenthunt
agenthunt / hello-react-custom-renderer-hostConfig.js
Last active May 11, 2021 16:18
hello-react-custom-renderer-hostConfig
const rootHostContext = {};
const childHostContext = {};
const hostConfig = {
now: Date.now,
getRootHostContext: () => {
return rootHostContext;
},
prepareForCommit: () => {},
resetAfterCommit: () => {},
@agenthunt
agenthunt / hello-react-custom-renderer-counter.js
Last active June 7, 2018 19:09
hello-react-custom-renderer-counter.js
import React, { Component } from 'react';
import logo from './logo.svg';
import './App.css';
class App extends Component {
constructor(props) {
super(props);
this.state = {
counter: 0
};