简体   繁体   English

如何在 React Native 中处理多个组件中的数据获取?

[英]How to handle data fetching in multiple components in React Native?

I am new to React Native.我是 React Native 的新手。 Currently, I have multiple components, and each component does several fetches before rendering.目前,我有多个组件,每个组件在渲染之前都会进行几次提取。 The idea that I have to make a loading screen while the app.js is rendering.我必须在 app.js 渲染时制作加载屏幕的想法。 But then, other components will still be loading when app.js is shown.但是,当显示 app.js 时,其他组件仍会加载。 What is the best way to do all the fetches in all components while loading the app.加载应用程序时在所有组件中进行所有提取的最佳方法是什么? I have found about Higher Order Component and Redux.我发现了有关高阶组件和 Redux 的信息。 However, I don't know what is the best approach to use.但是,我不知道什么是最好的使用方法。

I would say that there are 3 main concepts and realizations for today that solve the issue you have.我想说今天有 3 个主要概念和实现可以解决您遇到的问题。

There is no Best or Correct way to handle the global state, just one you chose.没有最佳或正确的方法来处理全局 state,只有您选择的一种。 One concept can be more familiar for you, other super-new.一个概念对你来说可能更熟悉,另一个是超级新的。 I would recommend you to read the documentation and one you think is easier to work with - is one you need.我建议您阅读文档,您认为更容易使用的文档是您需要的文档。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 React Native - 如何将 map 分成多个组件? - React Native - How to map into multiple components? 如何在React Native中添加多个组件? - How to add multiple components in React Native? React Native:在使用 useEffect 钩子获取数据时进行多次渲染 - React Native : multiple renders at fetching data with useEffect hook 如何使用react-native-element checbox和FlatList React Native来处理从json中获取复选框? - How to handle checkbox fetching from json using react-native-element checbox with FlatList React Native? 如何在 React Native 中处理多个 FlatList - How to handle multiple FlatLists in React Native 在 React 中处理多个复选框组件 - Handle multiple checkbox components in React 如何使用 react/react native 在单击时删除或隐藏多个组件 - How to delete or hide multiple components on click with react/react native 如何在多个React Native组件中保持可变电流的值 - How to keep the value of a variable current throughout multiple React Native components 如何使用React可加载和获取组件数据(如Next.js)进行服务器端渲染? - How to do Server Side Rendering in React With React Loadable and Fetching Data for Components (Like Next.js)? 在React Native中使用标头从API提取数据 - Fetching Data from an API with Headers in React Native
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM