当数据不再为null时,它将失败并显示错误未捕获的不变违规:与上次渲染相比,渲染了更多的钩子
export default function CableScreen({ navigation }) {
const { data, error, loading } = useQuery(CABLE_PROVIDERS)
const context = useContext(CableContext)
if (loading) {
return <Loader />
}
useEffect(() => {
if (data) {
context.setCableNetworks({
cableNetworks: data.cableProviders
})
}
})