Coderockr / backstage

Coderockr's recommended tools and components for development
8 stars 1 forks source link

Create React Library - Template para criar bibliotecas no NPM #12

Open juliabpp opened 4 years ago

juliabpp commented 4 years ago

Code: https://github.com/transitive-bullshit/create-react-library

Tutorial: https://levelup.gitconnected.com/create-your-own-react-library-in-2020-step-by-step-7c39eb1b2d7b

Troubleshoot

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 react-invalid-hook-call for tips about how to debug and

Below are the steps I followed :

  1. In Your Application: a) cd node_modules/react && npm link b) cd node_modules/react-dom && npm link

  2. In Your Library a) npm link react b) npm link react-dom

3)Stop your dev-server and do npm start again.

Também adicionei o código abaixo no package.json. Não tenho certeza se isso afetou algo "resolutions": { "/react": "16.7.0-alpha.2", "/react-dom": "16.7.0-alpha.2" },