我一直在尝试在 Expo 中加载字体,但我一遍又一遍地遇到相同的错误。
这是我的代码:
我的 Index.js 如下所示:
import WelcomePage from "./Authentication/WelcomePage";
export default function Page() {
return (
<WelcomePage/>
);
}
虽然我的欢迎页面看起来像这样
import {Link, useRouter} from "expo-router";
import {windowForm} from "../Design/WindowForm";
import {Button} from "react-native-paper";
import Styles from "../Design/styles";
import Constants from "expo-constants";
import {Inter_900Black, useFonts} from "@expo-google-fonts/inter";
const WelcomePage = () => {
const router = useRouter()
let [fontsLoaded] = useFonts({
Inter_900Black,
});
if (!fontsLoaded) {
return null;
}
return(
<View style={{width: windowForm().at(0), height:windowForm().at(1)}}>
<Text style={{fontFamily:'Inter_900Black'}}>
Hey
</Text>
</View>
)
}
export default WelcomePage
这是我不断收到的错误:
Warning: React has detected a change in the order of Hooks called by WelcomePage. This will lead to bugs and errors if not fixed. For more information, read the Rules of Hooks: https://reactjs.org/link/rules-of-hooks
包括这个:
上一个渲染
下一个渲染