Skip to content

Instantly share code, notes, and snippets.

@ryansolid
ryansolid / todos-localstate.jsx
Created April 9, 2019 04:13
LocalState Hook
import { createState, createEffect } from 'solid-js';
const LOCAL_STORAGE_KEY = 'todos-solid';
function createLocalState(value) {
// load stored todos on init
const stored = localStorage.getItem(LOCAL_STORAGE_KEY),
[state, setState] = createState(
stored ? JSON.parse(stored) : value
);
import React, { memo, useReducer, useCallback } from 'react';
import ReactDOM from 'react-dom';
function random(max) { return Math.round(Math.random() * 1000) % max; }
const A = ["pretty", "large", "big", "small", "tall", "short", "long", "handsome", "plain", "quaint", "clean",
"elegant", "easy", "angry", "crazy", "helpful", "mushy", "odd", "unsightly", "adorable", "important", "inexpensive",
"cheap", "expensive", "fancy"];
const C = ["red", "yellow", "blue", "green", "pink", "brown", "purple", "brown", "white", "black", "orange"];
const N = ["table", "chair", "house", "bbq", "desk", "car", "pony", "cookie", "sandwich", "burger", "pizza", "mouse",
import { root, useState } from 'solid-js';
import { r, selectWhen } from 'solid-js/dom';
let idCounter = 1;
const adjectives = ["pretty", "large", "big", "small", "tall", "short", "long", "handsome", "plain", "quaint", "clean", "elegant", "easy", "angry", "crazy", "helpful", "mushy", "odd", "unsightly", "adorable", "important", "inexpensive", "cheap", "expensive", "fancy"],
colours = ["red", "yellow", "blue", "green", "pink", "brown", "purple", "brown", "white", "black", "orange"],
nouns = ["table", "chair", "house", "bbq", "desk", "car", "pony", "cookie", "sandwich", "burger", "pizza", "mouse", "keyboard"];
function _random (max) { return Math.round(Math.random() * 1000) % max; };
@ryansolid
ryansolid / cr-react.jsx
Last active June 22, 2022 19:23
Component Register React
import { register, compose } from 'component-register'
import withReact from 'component-register-react'
import React, { Component } from 'react'
// Normal React Component
class MyComponent extends Component
constructor(props) {
this.state = {greeting: 'Hello'}
}