Issue
Newbie to expo-router & React-Native
I have two screens (a & b) for example, b being a modal which is presented over a.
How would I go about passing data from screen b (the modal) back to screen a?
File Structure
app
-(tabs)
--account
---index.jsx (screen a)
-create-account
--index.jsx (screen b)
Usually when you are adding a screen to the stack you would use useLocalSearchParams();
however, I am popping a screen off the stack and the screen behind is already rendered.
Solution
Figured it out. Instead of calling router.back()
you can call router.push({})
with an empty pathname
Screen Receiving Data
const params = useLocalSearchParams();
const { ANY_PARAMS_HERE } = params;
Screen Sending Data
const goBack = () => {
router.push({
pathname: "/",
params: {
SOME_OBJECT: SOME_OBJECT_VALUE,
},
});
};
Answered By - David Henry
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.