I'm working on a react native typescript project.
How do I set my context object to the data I receive as a response from an api call?
I don't want to have to make the API call every time I load the component?So I want to check the context if it's there , don't make the call.
I see a lot of examples , but none seem to set the state without a function. I just want to be set the context to a new context object. Even if state never changes.
Just set context to a new context then when the component loads again, don't make the API call because the context is already set.
Looking for a hook based example or class based example, preferably hooks.
The documentation either shows just how to pass the context or just how to set the state with a function. I want to simply set the context to be whatever I originally requested for.
The object itself is a Location[] with strings such as name, address, city , state , zip, phone etc so there may be multiple Locations.