Open History to see the last commit
1import { useEffect, useState } from 'react'
2import { DevtoolsEventClient } from './eventClient.ts'
3β
4export default function CustomDevtoolPanel() {
5 const [state, setState] = useState<
6 { count: number; history: Array<number> } | undefined
7 >()
8β
9 useEffect(() => {
10 // subscribe to the emitted event
11 const cleanup = DevtoolsEventClient.on('counter-state', (e) =>
12 setState(e.payload),
13 )
14 return cleanup
15 }, [])
16β
17 return (
18 <div>
19 <div>counter state: {state?.count}</div>
20 <div>counter history: {JSON.stringify(state?.history)}</div>
21 </div>
22 )
23}