提问人:Paulin.f 提问时间:3/23/2023 最后编辑:Mike SzyndelPaulin.f 更新时间:4/2/2023 访问量:200
react native expo 应用程序中的 redux-toolkit (createAsyncThunk) 问题
Problem with redux-toolkit (createAsyncThunk) in react native expo app
问:
我的问题是在 Expo 的 react-native 应用程序上的 redux-toolkit 上。 为了把你放在上下文中,我是一个初学者。
这是我的代码:
export const fetchStationsInformations = createAsyncThunk(
"stations/fetchStationsInformations",
async () => {
console.log(process.env.NODE_ENV);
if (process.env.NODE_ENV === "test") {
return require("@data/stationsInformations.json");
}
const response = await api.get("/stationsInformations");
return response.data;
}
);
export const fetchStationsStatus = createAsyncThunk(
"stations/fetchStationsStatus",
async () => {
console.log(process.env.NODE_ENV);
if (process.env.NODE_ENV === "test") {
return require("@data/stationsStatus.json");
}
const response = await api.get("/stationsStatus");
return response.data;
}
);
我想知道为什么在上面的代码中,当我让我的文件中有函数 fetchStationsInformations 和 fetchStationsInformations 时,我收到此错误:
ERROR [Error: Exception in HostFunction: Compiling JS failed: 2:20:invalid expression Buffer size 613 starts with: 5f5f642866756e6374696f6e28676c6f and has protection mode(s): rw-p]
虽然不使用 fetchStationsStatus 方法,但使用了 fetchStationsInformations。 我尝试用“expo start --clear”来清算现金。
但是,如果我删除fetchStationsInformation方法,那么它就可以工作了。 我看了很多文档和 StackOverflow,但我找不到解决方案。
答:
0赞
Paulin.f
3/27/2023
#1
这个问题很特别,而且很傻!中的导入文件为空。我知道它是空的,但我不知道空文件会导致崩溃。fetchStationStatus
评论