import React, { useState } from 'react';import ReactDOM from 'react-dom';// import useUpdate from './useUpdate.js';const rootElement = document.querySelector('#root');let _state = [];let _index = 0;const myUseState = (initialValue) => {const currentIndex = _index;_index += 1;_state[currentIndex] = _state[currentIndex] || initialValue;const setState = (newState) => {_state[currentIndex] = newState;render();}return [_state[currentIndex], setState];}const render = () => {_index = 0;ReactDOM.render(<App />, rootElement);}const App = () => {const [n, setN] = useState(0);const [m, setM] = useState(0);return (<div>n: {n} <button onClick={() => setN(n + 1)}>+1</button><hr />m: {m} <button onClick={() => setM(m + 1)}>+1</button></div>)}ReactDOM.render(<App />, rootElement);
