-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathsidepanel.tsx
37 lines (29 loc) · 961 Bytes
/
sidepanel.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import "./globals.css"
import { useEffect, useState } from "react"
import HeroTitle from "~components/blocks/HeroTitle"
function IndexSidePanel() {
const [data, setData] = useState("Loading...")
useEffect(() => {
const messageListener = function (request, sender, sendResponse) {
if (request.action === "send_to_sidepanel") {
setData(request.payload)
}
}
chrome.runtime.onMessage.addListener(messageListener)
// Cleanup listener on component unmount
return () => chrome.runtime.onMessage.removeListener(messageListener)
}, [])
return (
<div
style={{
display: "flex",
flexDirection: "column",
padding: 16,
zIndex: 1000
}}>
<HeroTitle color="black" />
<p className="text-lg">{data}</p>
</div>
)
}
export default IndexSidePanel