0

我需要一些关于 react-native 中的 redux、reduxsauce、reducers 和 apisauce 的帮助,这是发布它的好地方吗?

基本上我有一个 api.js 文件

import apisauce from 'apisauce';
import AppConfig from '../../config/app-config';
const create = (baseURL = AppConfig.apiUrl) => {
}

当我调用 getAllUsers 之类的东西时,比如说,我有调用 reduxsauce 类型的动作和减速器的调度程序。

问题是,那里的那个小 baseURL 是硬编码的 atm,我想可变地使用它并且基本上改变 apisauce 但我想从应用程序中的选择中执行此操作,该代码已连接到它

import GlobalStore from 'react-native-global-state-hooks';
const instanceURLStore = new GlobalStore("http://localhost:8080/", null, 'GLOBAL_INSTANCE_URL');
export const useInstanceURL = instanceURLStore.getHook();

,正如你所知道的,它使用了一个很酷的 react-native 钩子工具。

你们知道我该如何解决这个问题吗?基本上这真的很容易,但我知道我不能只在 api.js 中这样做

import {useInstanceURL} from '../../../config/instanceURL';
const [instanceURL, setter, isUpdated] = useInstanceURL();

接着

const create = (baseURL = instanceURL) => {
},

但它不起作用,因为 ofc,api.js 用于 react-native 构建。

我在此声明,我对 react 真的一无所知,而且我对这个 reduxsauce 感到很困惑,我并不真正了解它是如何工作的。

4

0 回答 0