Skip to content

Commit

Permalink
Remove debug log and clean up event listener
Browse files Browse the repository at this point in the history
Signed-off-by: Axel Boberg <[email protected]>
  • Loading branch information
axelboberg committed Apr 24, 2024
1 parent 08a0290 commit 2c3ce52
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions plugins/button/app/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,23 @@ export default function App () {
React.useEffect(() => {
async function getItem (itemId) {
const item = await bridge.items.getItem(itemId)
console.log('Got item', item)
setItem(item)
}
getItem(itemId)
}, [itemId])

React.useEffect(() => {
bridge.events.on('item.change', newItem => {
function handleItemChange (newItem) {
if (newItem?.id !== item?.id) {
return
}
setItem(newItem)
})
}

bridge.events.on('item.change', handleItemChange)
return () => {
bridge.events.off('item.change', handleItemChange)
}
}, [item])

function handleItemChange (itemId) {
Expand Down

0 comments on commit 2c3ce52

Please sign in to comment.