Skip to content

Commit 1735461

Browse files
docs(troubleshooting): create-react-app .cjs #1067
1 parent 5a22dd1 commit 1735461

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

docs/docs/troubleshooting.mdx

+20
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,26 @@ If you're running into this on a project not using webpack, please [submit a bug
180180

181181
:::
182182

183+
## The tooltip component is `undefined` ([#1067](https://github.com/ReactTooltip/react-tooltip/issues/1067))
184+
185+
This might be related to an issue with `create-react-app` not supporting `.cjs` files, which is the default extension for the ReactTooltip dist file (`react-tooltip.min.cjs`).
186+
See [`cra`'s issue #12700](https://github.com/facebook/create-react-app/issues/12700#issuecomment-1463040093) for the recommended way to fix this for all of your project dependencies.
187+
188+
If you wish to only fix this for `react-tooltip`, see below.
189+
190+
By default, your project will be importing the `react-tooltip.min.cjs` file. To workaround this, you must change the ReactTooltip `package.json` file (not the one on the root of your project!).
191+
To do this, run the following inside your project directory:
192+
193+
```sh
194+
// if you're on Windows, just download the `.patch` file manually
195+
wget https://github.com/ReactTooltip/react-tooltip/files/12195501/react-tooltip-1067.patch
196+
git diff react-tooltip-1067.patch
197+
```
198+
199+
This will apply the necessary changes (which you can check out for yourself).
200+
The only problem with this approach is that reinstalling `react-tooltip`, or cloning your project into a new environment, means you'll have to apply the changes again.
201+
For that reason, consider the [recommended solution](https://github.com/facebook/create-react-app/issues/12700#issuecomment-1463040093) mentioned above, or using [`patch-package`](https://www.npmjs.com/package/patch-package).
202+
183203
## Next.js `TypeError: f is not a function`
184204

185205
This problem seems to be caused by a bug related to the SWC bundler used by Next.js.

0 commit comments

Comments
 (0)