-2

ReactJS newbie question. I'm making use of Material-UI autocomplete Google Places API to enable user to lookup location. Along with the location I get a "place_id" returned from the Google Places API. The question is, I'm not clear on best practice for storing the "place_id" for the purpose of an eventual form submit in ReactJS. Normally I would just store it to a hidden field but would like to know what the best practice is for doing so in ReactJS? You can see my demo project https://codesandbox.io/s/twilight-waterfall-3okx4?file=/src/index.js but note that I currently have the Google Places API lookup disabled since I don't want my key to be public. Thanks in advance for any tips and advice.

sybercoda
  • 495
  • 3
  • 6
  • 24
  • Does this answer your question? [localStorage vs sessionStorage vs cookies](https://stackoverflow.com/questions/29960037/localstorage-vs-sessionstorage-vs-cookies) – Amruth Aug 07 '21 at 12:22
  • @Amruth That's a bit of different scenario where the value has to persist. – sybercoda Aug 07 '21 at 12:23

1 Answers1

0

Silly me. Just realized that because I'm saving the entire returned Google Places object in state I can reference the place ID at any time, as needed.

sybercoda
  • 495
  • 3
  • 6
  • 24