import useSWR from 'swr' function Profile() { const { data, error, isLoading } = useSWR('/api/user', fetcher) if (error) return <div>failed to load</div> if (isLoading) return <div>loading...</div> return <div>hello {data.name}!</div> } ãã®ä¾ã§ã¯ãuseSWR ããã¯ã¯ key æåå㨠fetcher é¢æ°ãåãåãã¾ãã key ã¯ãã¼ã¿ã®ä¸æãªèå¥åï¼é常㯠API ã® URLï¼ã§ãfetcher ã«æ¸¡ããã¾ãã fetcher ã¯ãã¼ã¿ãè¿ãä»»æã®éåæé¢æ°ã§ããã¤ãã£ãã® fetch ã Axios ã®ãããªãã¼ã«ã使ããã¨ãã§ãã¾ãã ãã®ãã
{{#tags}}- {{label}}
{{/tags}}