This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from "react"; | |
import ReactDOM from "react-dom"; | |
import { DragDropContext, Droppable, Draggable } from "react-beautiful-dnd"; | |
// fake data generator | |
const getItems = count => | |
Array.from({ length: count }, (v, k) => k).map(k => ({ | |
id: `item-${k}`, | |
content: `item ${k}` | |
})); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {useCallback, useEffect, useState} from 'react'; | |
const Subie = (subs = [], _unsub = it => subs.splice(subs.indexOf(it) >>> 0, 1)) => [ | |
it => ((subs.push(it), () => _unsub(it))), | |
(...data) => subs.slice().map(f => (f(...data))) | |
]; | |
const useForceUpdate = () => { | |
const [, set] = useState(Object.create(null)); | |
return useCallback(() => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {h, render, Fragment, Host} from './little-vdom'; | |
import {someSubscription, anotherSub} from './store'; | |
const CounterAndSubscriber = (props, {count = 0}, update) => { | |
return( // in order to achieve hook-like functionality | |
// you can tie into the web component lifecycle | |
<Host lifeCycle={() => { // | |
// call update to rerender this component |