my code is
export default function useFetch(fetchFunction, param) {
const cache = useContext(cacheContext);
const [state, dispatch] = useReducer(fetchReducer, initialValue);
useEffect(() => {
if (cache.page[param]) {
dispatch({ type: ACTIONS.success, payload: cache.page[param] });
console.log("cache");
return;
}
// other code below
)
But my app is failing in the conditional operator. Im expecting that if cache.page[param] is empty, keep executing the code below. For example, if i got the param "0"
i get the error "TypeError: Cannot read property '0' of null"
and my app crashes
question from:
https://stackoverflow.com/questions/65838440/why-is-my-app-failing-in-a-conditional-operator 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…