#why though
import React from "https://esm.sh/react";
import ReactDOM from "https://esm.sh/react-dom";
function useSleepyEffect(fn) {
React.useEffect(() => {
const id = setTimeout(fn, 1000);
return () => {
clearTimeout(id);
};
});
}
function App() {
const [i, setI] = React.useState(0);
const [x, setX] = React.useState(0);
const [y, setY] = React.useState(1);
function reset() {
setX(0);
setY(1);
setI(0);
}
useSleepyEffect(() => {
setI(i + 1);
setX(y);
setY(x + y);
});
return (
<div>
fibonacci <sub>{i}</sub> = {x}
<br />
<button onClick={reset}>Reset</button>
</div>
);
}
ReactDOM.createRoot(document.body).render(<App />);
syntax highlighting by codehost
Try it on CodePen!
hmmm.... so u need a window and an instance to make a surface... and you need an instance and a surface to make an adaptor and that will give you a device??
Ā Ā