This file contains hidden or 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 { useRef } from "react"; | |
const ALL_MEDIA_RECORDER_EVENTS = [ | |
"dataavailable", | |
"error", | |
"pause", | |
"resume", | |
"start", | |
"stop", | |
]; |
This file contains hidden or 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 { useStore, updateState } from './store'; | |
function App() { | |
const store = useStore(); | |
return ( | |
<div> | |
<button | |
onClick={() => { | |
updateState({ |
This file contains hidden or 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 { useReducer } from 'react'; | |
import { todoReducer, TodoActionType } from './todos'; | |
function App() { | |
const [state, dispatch] = useReducer(todoReducer, []); | |
function handleCreateNewTodo(ev: React.FormEvent<HTMLFormElement>) { | |
ev.preventDefault(); | |
const content = String(new FormData(ev.currentTarget).get('content')); | |
dispatch({ |
This file contains hidden or 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 { useEffect, useState } from 'react'; | |
export const createImperativeState = <State>( | |
initialState: State | (() => State) | |
) => { | |
let listeners: Array<(state: State) => void> = []; | |
let memoryState: State = | |
initialState instanceof Function ? initialState() : initialState; |
OlderNewer