Question
What does the code snippet to the right output by console.log?
React quiz · 27
Question
Code
1'infiniteLoopProtection:false'
2
3import * as React from "react";
4import { useState, useEffect} from "react";
5import { createRoot } from "react-dom/client";
6
7function App() {
8 const [state] = useState(0)
9 console.log(1)
10
11 const start = Date.now()
12 while (Date.now() - start < 50) {
13 window.timestamp = Date.now()
14 }
15
16 useEffect(() => {
17 console.log(2)
18 }, [state])
19
20 Promise.resolve().then(() => console.log(3))
21
22 setTimeout(() => console.log(4), 0)
23
24 return null
25}
26
27const root = createRoot(document.getElementById('root'));
28root.render(<App/>)