When using getOverlayAnchorList. how to get the id of the parent element?

When using getOverlayAnchorList. how to get the index of element?
4 Replies
.snkt
.snktOP•2y ago
export const getOverlayAnchorList: PlasmoGetOverlayAnchorList = async () =>
document.querySelectorAll(".actionsCell-734864237")
export const getOverlayAnchorList: PlasmoGetOverlayAnchorList = async () =>
document.querySelectorAll(".actionsCell-734864237")
const PlasmoOverlay = () => {
useEffect(() => {
getAdsData()
}, [])

return (
<div className="mt-14">
<div className="button-30 w-44" role="button">
Repost
</div>
</div>
)
}
const PlasmoOverlay = () => {
useEffect(() => {
getAdsData()
}, [])

return (
<div className="mt-14">
<div className="button-30 w-44" role="button">
Repost
</div>
</div>
)
}
if there is some kind of index I can use to identify each element?
Arcane
Arcane•2y ago
@.snkt has reached level 1. GG!
.snkt
.snktOP•2y ago
as I want to perform different action on each button press. I have solved it by getting parent node id using react ref.
lab
lab•2y ago
You can access the anchor itself via the anchor object passed down to the overlay comp:
const PlasmoOverlay = ({anchor}) => {
// anchor.element <- this should be the anchor you queried. Then you can do anchor.element.parent if the parent has unique ID
}
const PlasmoOverlay = ({anchor}) => {
// anchor.element <- this should be the anchor you queried. Then you can do anchor.element.parent if the parent has unique ID
}
@.snkt
Want results from more Discord servers?
Add your server