How do I retrieve data with Plasmo storage api

I have the following code in a JSX component
const [selectedDeck, setSelectedDeck] = useStorage("selectedDeck", null)
...
setSelectedDeck(deck)
const [selectedDeck, setSelectedDeck] = useStorage("selectedDeck", null)
...
setSelectedDeck(deck)
In my contents/highlighter.ts file i have the following code: const storage = new Storage()
class MediumHighlighter extends HTMLElement {
...
async highlightSelection() {
...
const selectedDeck: any = await storage.get("selectedDeck")
console.log("selectedDeck: " + selectedDeck)
...
}
}
class MediumHighlighter extends HTMLElement {
...
async highlightSelection() {
...
const selectedDeck: any = await storage.get("selectedDeck")
console.log("selectedDeck: " + selectedDeck)
...
}
}
I have already verified that in the JSX component that setSelectedDeck is setting selectedDeck properly but I get null when I log from my contents/highlighter.ts
2 Replies
BrianCao
BrianCaoOP13mo ago
I was told by pallas that the react useStorage hooks use local storage but nothing shows up here
No description
BrianCao
BrianCaoOP13mo ago
issue solved. I just changed selectedDeck to selected_deck in both files 😐
Want results from more Discord servers?
Add your server