New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
app.tsx 条件判断返回null会报错找不到页面实例 #15506
Comments
taro-bot2
bot
added
F-react
Framework - React
T-weapp
Target - 编译到微信小程序
V-3
Version - 3.x
labels
Apr 13, 2024
This was referenced Apr 20, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
相关平台
微信小程序
小程序基础库: H5
使用框架: React
复现步骤
`import { Provider } from "react-redux";
import intl from "react-intl-universal";
import Taro from "@tarojs/taro";
import { useEffect, useState } from "react";
import { store } from "./store";
function App({ children }: any): any {
const [localeDone, setLocaleDone] = useState(false);
useEffect(() => {
Taro.request({
url: "get url api", // 异步获取json文件
success(res: any = {}) {
if (res.statusCode === 200 && res.url) {
Taro.request({
url: res.url,
success(result: any = {}) {
console.log("返回json", result.data);
if (result.statusCode === 200 && result.data) {
intl
.init({
currentLocale: "en-US",
locales: {
"en-US": result.data.EN,
"zh-CN": result.data.CH,
},
})
.then(() => {
setLocaleDone(true);
});
}
},
});
}
},
});
}, []);
return {localeDone ? children : null};
}
export default App;`
期望结果
app.tsx 可以返回null,或者当state变化时children可以重渲染
实际结果
没有找到页面实例
The text was updated successfully, but these errors were encountered: