Search code examples
react-nativereact-native-fbsdk

Using components to retrieve data without returning a layout in React Native


What I'm ultimately trying to achieve

Requesting and retrieving data from a 3rd party API (Facebook Graph API) by encapsulating the request within its own component.

My proposed attempt

  1. Inside the component displaying the current layout, main create an instance of the data retrieving component, fbRetrieveData and asynchronously calls a retrieve function.
  2. The retrieve function within the fbRetrieveData then gets the data, manipulates it as necessary and returns it back to the main component.
  3. The main component then displays the data.

What I'm struggling with

I've found articles on how to do this, such as this one, but they all seem to require that some layout is returned and/or that the retrieving component is called by being part of the layout.

Any help would be hugely appreciated!


Solution

  • In case anyone comes across this, I have decided to just use a JavaScript class instead to avoid having to return null as previously proposed.