0

I have a form in react native which allows uploading multiple pictures, but actual uploading is only done after clicking "Submit" button, which in this case I am saving the selected images to the state via redux and it would live in the state until the form is submitted, or the app is closed.

zyneragetro
  • 139
  • 1
  • 2
  • 13
  • @Moistbobo I would beg to differ that base64 is a data serialization method. – Elias Sep 19 '21 at 10:04
  • 1
    Actually, since `react-native-image-picker` is being used, the `uri` should be used instead as storing the base64 of an image is expensive for larger images. I've deleted my previous comment which recommended storing the image as a base64 as I decided it's misleading. – Moistbobo Sep 19 '21 at 11:18

1 Answers1

0

While it is commonly frowned upon to save form data in redux, if you are just saving the URI string and not the base64 compressed data, I don't see an issue.

However, if you want a cleaner architecture, I would suggest saving the form data (and the image URIs) in a local storage like AsyncStorage and then reading that storage on refresh instead of putting the data in redux.