Closed efstathiosntonas closed 1 year ago
@efstathiosntonas Try 0.8.20 and see if it works for you?
@ammarahm-ed the same issue. I've console.log(props)
:
----------APP OPENS------
[] global
-------- SHEET OPENS------
LOG {"payload": {"bookmark": {"__typename": "post_bookmark", "id": "20f9e30c-983b-4b18-9219-9cd6e1a1deea", "post": [Object]}, "navigation": {"addListener": [Function addListener], "canGoBack": [Function canGoBack], "dispatch": [Function dispatch], "getId": [Function getId], "getParent": [Function getParent], "getState": [Function anonymous], "goBack": [Function anonymous], "isFocused": [Function isFocused], "navigate": [Function anonymous], "pop": [Function anonymous], "popToTop": [Function anonymous], "push": [Function anonymous], "removeListener": [Function removeListener], "replace": [Function anonymous], "reset": [Function anonymous], "setOptions": [Function setOptions], "setParams": [Function anonymous]}}, "sheetId": "bookmark_action_sheet"}
-------------HERE I CLOSED THE SHEET------------------------
LOG ["global"] $$-auto-bookmark_action_sheet-global-provider
LOG {"payload": undefined, "sheetId": "bookmark_action_sheet"}
LOG {"payload": undefined, "sheetId": "bookmark_action_sheet"}
ERROR TypeError: Cannot read property 'bookmark' of undefined
@efstathiosntonas How are you setting the payload?
I call it like this:
const onOpenPostMainSheet = useCallback(async () => {
await SheetManager.show("bookmark_action_sheet", {
payload: { bookmark, navigation }
});
}, [bookmark, navigation]);
@efstathiosntonas That's opening the sheet, how are you closing it/setting payload?
That's how I'm closing it, note that this works fine on 0.8.13
await SheetManager.hide("bookmark_action_sheet");
And so payload inside the sheet is undefined? Let me see.
Yes, when it opens the payload is there just fine, the moment I close it it breaks. Maybe there's a race condition and props are cleaned up too early.
@efstathiosntonas Why do you need props inside the sheet after it is closed?
I do not need them any more. They're part of a useCallback
dependencies array:
const onRemovePostBookmark = useCallback(async () => {
await SheetManager.hide("bookmark_action_sheet");
await removePostBookmark({
variables: {
bookmark_id: props.payload.bookmark.id
},
update(cache) {
cache.evict({
id: cache.identify({
id: props.payload.bookmark.id,
__typename: "post_bookmark"
})
});
cache.gc();
}
});
track("User Removed Bookmark From a Post", {
post_id: props.payload.bookmark.post.id,
profile_id: currentUser().uid
}).catch();
}, [
props.payload.bookmark.id,
props.payload.bookmark.post.id,
removePostBookmark,
track
]);
We need to treat them as optional from now on? 🤔 If yes, then I'll have to go through 30 action sheets 🥴
Okay, I will try to repro this locally, not sure what I changed that is causing this.
Thanks @ammarahm-ed, keep it up! I ll stick to 0.8.13
for now
@efstathiosntonas Try 0.8.21
. The problem is using props.payload.bookmark.id
instead of simply props.payload
but now it should work.
@ammarahm-ed works as charm. Thank you brother.
Sorry for the bad issue title.
After upgrading to 0.8.19 (and prior versions down to 0.8.13 which is working fine) every time I close the sheet everything that is attached to the payload is undefined. Don't know if something has changed in the props in the latest versions (since there's no changelog).
Here's the payload I'm using:
The moment I close the sheet
bookmark
andnavigation
are undefined.sheets.tsx
: