docz: Stuck trying to run docz dev
Just tried docz rc 1.0.0 rc3 and got the following multiple instances of error:
✖ fatal Error parsing static types ✖ error Error: No suitable component definition found. at parse (/Users/bugzpodder/ui/node_modules/docz-core/node_modules/react-docgen/dist/parse.js:70:13) at Object.defaultParse [as parse] (/Users/bugzpodder/ui/node_modules/docz-core/node_modules/react-docgen/dist/main.js:64:29) at resolve (/Users/bugzpodder/ui/node_modules/docz-core/dist/index.js:1412:38) at new Promise (<anonymous>) at jsParser (/Users/bugzpodder/ui/node_modules/docz-core/dist/index.js:1409:12) at Promise.all.files.map (/Users/bugzpodder/ui/node_modules/docz-core/dist/index.js:1430:15) at Array.map (<anonymous>) at docgen (/Users/bugzpodder/ui/node_modules/docz-core/dist/index.js:1427:42)
Turning debug: off and the UI is stuck at this: ● Docz █████████████████████████ building (10%) 2/4 modules 2 active …/node_modules/url/url.js
After about 5 minutes I get a build success with the following UI error: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:
- You might have mismatching versions of React and the renderer (such as React DOM)
- You might be breaking the Rules of Hooks
- You might have more than one copy of React in the same app See https://fb.me/react-invalid-hook-call for tips about how to debug and fix this problem.
10 | useDataServer('ws://127.0.0.1:60505')
11 | return (
12 | <Theme linkComponent={Link} db={database}>
> 13 | <Routes imports={imports} />
| ^ 14 | </Theme>
15 | )
16 | }
11 | const root = document.querySelector('#root')
12 | const render = (Component = Root) => {
13 | onPreRender()
> 14 | ReactDOM.render(<Component />, root, onPostRender)
| ^ 15 | }
16 |
17 | render(Root)
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 25
- Comments: 26 (4 by maintainers)
same issue
After trying all of the above, I also found that upgrading to V1 results in the same stack trace no matter how I fix versions of React, etc.
How I & @alexhawkins fixed it
My situation was that I have a monorepo that’s managed by npm scripts, no monorepo tool like Lerna.
I have a frontend folder that contains all of our Gatsby apps. The frontend repo package.json has
.docz
to.gitignore
frontend
folder,rm -rf node_modules package-lock.json .docz
frontend
folder,npm i
frontend
folder,docz dev
Should work out. For people reading this in the future, your
react
dependencies might have to match up with whatever React version is in https://github.com/pedronauck/docz/blob/master/core/docz/package.jsonI’m still having this issue. If I install Docz in my React app, I get more than one copy of React in the same app:
I tried using npm force-resolutions and it does not solve this issue in my case.
I’ve noticed that Docz uses the following versions of react and react-dom: “react”: “^16.8.0”, “react-dom”: “^16.8.0”
And my project is using 16.13.1, could this be the issue?
Please any help would be very much appreciated!
Any updates on this? I too tried pinning react to 16.8.6, removed node_modules and package-lock.json to get deduped react versions, but still encounter this error
Ran into this today and looked in the
package.json
file for Docz. I saw that the React typings they are using is for^16.8.2
. I was using React^16.8.3
for the project I have Docz on.Make sure you’re running the following versions of React in the project you have Docz on:
After that, blast away the
.docz
folder andnode_modules
. Finally, re-installnode_modules
and run docz and you should be good!What’s interesting is that I don’t see any peer dependencies stating the version of React that needs to be installed to run the project. @pedronauck Happy to put in a PR to update the Readme and add the specific React version to the
package.json
.Hey @wldcordeiro
V2 will get out of RC status next Monday November 25.
Did you give it a try ?
I encourage you to try it and if you face any problems we’ll be happy to help ! Or feel free to wait for next week 👍
@pedronauck It doesn’t.
I pinned my react to 16.8.2 in package.json and docz automatically installs 16.8.6 so now I have two versions of react installed (according to yarn why) I changed my react to 16.8.6 and now there is only one version but it still won’t stack with the same errors above.
I get this problem on latest of the v1 releases. Seeing as v2 seems to have stalled out on the infinite RC status I worry about this package stability for either major version.
What @mwood23 told should fix this problem.