Repository navigation
Replies: 1 comment
|
Yes. With CommonJS, const React = require('react');
const useSWR = require('swr').default;
const fetcher = (url) => fetch(url).then((res) => res.json());Your component can then call I checked SWR 2.5.1: |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Hi,
I'd like to know if CommonJS is supported by SWR.
I'm asking because doing this
const useSWR = require("swr")leads touseSWR is not a function. I already saw a thread related to this, but I couldn't find a way around this.For instance, modifying your basic example application from https://swr.vercel.app/es-ES/examples/basic by converting it to CommonJS leads to this issue:
Thanks.
All reactions