LoginSignup
0
0

react-router-domのLinkで遷移時に destroy is not a function TypeError: destroy is not a function のエラーが出る時のエラー回避方法

Posted at

変更前

    useEffect(async () => {
        setLoading(false);
        const res = await api.get('/clients');
        console.log('get clients');
        console.log(res);
        setClients(res.result);
    }, []);

変更後

    const getClients = async () => {
        const res = await api.get('/clients');
        console.log('get clients');
        console.log(res);
        setClients(res.result);
    };

    useEffect(() => {
        setLoading(false);
        getClients();
    }, []);

でエラーを回避できた。
useEffect にasync は基本つけない方が良さそう、とだけ。
以前は何も考えずに書いていた気もしてる。
以上備忘録。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0