Creating NPM project both for Vue and React. How to import a Vue and React Hook into index.js with error

236 Views Asked by At

Anyone knows how I can import each of below function in Vue and React without an error? Right now I am getting an error if I am importing vueFetch and reactFetch.

So if am importing vueFetch into a Vue project, I am getting an error for React that React is not defined and the same applies if I import reactFetch (Vue ref not defined).

import { vueFetch } from './composables/vue/vue-fetch';
import { reactFetch } from './composables/react/react-fetch';

export { vueFetch, reactFetch };

I am trying to make a Vue and React NPM package, but I only have one index file, and I need to import both Hook into the single index file. So I do not need to create 2 packages.

here is the link to the package: https://www.npmjs.com/package/use-lightweight-fetch

0

There are 0 best solutions below