Skip to content

Fixes the issue when npm package / exported Component uses React import, so webpack resolves it not from global node_modules/react but instead from package directory.

License

Notifications You must be signed in to change notification settings

gerwld/docusaurus-plugin-fix-react

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

docusaurus-plugin-fix-react

Fixes the issue when npm package / exported Component uses React import, so webpack resolves it not from global node_modules/react but instead from package directory, which causes Hooks and other parts of React not working properly.

Installation:

## NPM
npm i docusaurus-plugin-fix-react
## yarn
yarn add docusaurus-plugin-fix-react
## PNPM
pnpm add docusaurus-plugin-fix-react

Add to your docusaurus.config.js:

/** @type {import('@docusaurus/types').Config} */
const config = {
plugins: ["docusaurus-plugin-fix-react"],
// ... rest of the config
}

~ or, alternatively:

/** @type {import('@docusaurus/types').Config} */
const config = {
plugins: ["./node_modules/docusaurus-plugin-fix-react/index.js"],
// ... rest of the config
}

If you use PNPM and @type errors appear this may help:

# add next line to your .npmrc file
node-linker=hoisted

License

MIT © Patryk Jaworski

About

Fixes the issue when npm package / exported Component uses React import, so webpack resolves it not from global node_modules/react but instead from package directory.

Resources

License

Stars

Watchers

Forks

Packages

No packages published