ammarahm-ed / react-native-actions-sheet

A Cross Platform(Android, iOS & Web) ActionSheet with a flexible api, native performance and zero dependency code for react native. Create anything you want inside ActionSheet.
https://rnas.vercel.app
MIT License
1.49k stars 121 forks source link

[feat request] Add ability to update payload of Action Sheet via SheetManager #286

Closed Roka20012 closed 1 year ago

Roka20012 commented 1 year ago

Hello, @ammarahm-ed first of all thanks for the great package!

I didn't see any mentions of how I can update my payload data in case it's dynamic The only way I ended up with it was to put my queries into ActionSheet and update data dynamically there

I am using SheetManager to manage my ActionSheet

Is there any way to do it or would it be a good feature for this package?

Let me know what you think, please.

johnny-mcfadden-dailypay commented 1 year ago

What are you trying to achieve? Are you trying to open an action sheet with different prop values? you should be able to just use the sheet manager show method to pass through a props payload and then access inside your action sheet component via props.payload.thePropName

Roka20012 commented 1 year ago

What are you trying to achieve? Are you trying to open an action sheet with different prop values? you should be able to just use the sheet manager show method to pass through a props payload and then access inside your action sheet component via props.payload.thePropName

@johnny-mcfadden-dailypay Hello thanks for the response) Basically, I want to open an action sheet, update value in that action sheet on the fly without closing and open it again with other data

Do you know how to achieve this behavior?

johnny-mcfadden-dailypay commented 1 year ago

Are you looking to:

  1. open the action sheet with prop values?
  2. whilst the action sheet is open and the user is looking at the action sheet, change the information displayed on the action sheet? Is this from a user interaction like a button click or an api call that runs when the action sheet opens?
Roka20012 commented 1 year ago

Yes for example I open the action sheet and need to load some data from API, and update action sheet with this data

Roka20012 commented 1 year ago

@johnny-mcfadden-dailypay

Is this from a user interaction like a button click or an api call that runs when the action sheet opens?

Exactly this one

johnny-mcfadden-dailypay commented 1 year ago

Can you not just use normal react patters for this? When the api call finishes, update a local state hook inside the action sheet and use the state hook data as your presentational piece. IF you need to initially take in props to the action sheet you could just set this data as your initial state hook value, then override with an api call response.

Roka20012 commented 1 year ago

@johnny-mcfadden-dailypay not sure it will work, but I will give it a try, thanks 👍

AyoCodess commented 5 months ago

Can you not just use normal react patters for this? When the api call finishes, update a local state hook inside the action sheet and use the state hook data as your presentational piece. IF you need to initially take in props to the action sheet you could just set this data as your initial state hook value, then override with an api call response.

having to create separate state to mimic the state controlled outside the action sheet is a very difficult experience, the props.paylaod are not updated on the fly, we literally need to unmount the action sheet and remount it to see state updates.

tldr: anything that gets passed to the sheets as a prop "props.payload" does not re-render the UI in the bottom sheet when updated. You have to close the sheet to see the update that has successful ran.