Local react library testing .... how to achieve that?

57 views Asked by At

Yesterday I asked a very specific question about how to continue with a setup I already started

please see this thread

Obviously I already started this the wrong way ... so now I'm going for a more general question:

Can you give me a detailed description how to be able to

  • Edit an already forked react library with a very specific react version and other dependencies. This library uses class based components
  • Create a new local test project that uses this library directly from its sources ... ideally without building the library first. But if building is necessary, please tell me. The test project is using function based components with hooks
  • Ideally, it should be possible to debug the test project together with the library in the browser in development mode. But if this is not possible, please also tell me

Is a setup like this even possible? If not, how are people doing this? I cannot believe this isn't an "everydays setup" ...

I've been looking around for days ... believe me, I think I was very comprehensive. Yet, no success

The most frequent error I got is this (after using npm link to link the test project to the library folder). It is in the browser, the npm start command ran without any error:

Uncaught 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:
1. You might have mismatching versions of React and the renderer (such as React DOM)
2. You might be breaking the Rules of Hooks
3. You might have more than one copy of React in the same app
See `a link` for tips about how to debug and fix this problem.
    at resolveDispatcher (react.development.js:1590:1)
    at useContext (react.development.js:1598:1)
    at emotion-element-c39617d8.browser.esm.js:37:1
    at renderWithHooks (react-dom.development.js:16305:1)
    at updateForwardRef (react-dom.development.js:19226:1)
    at beginWork (react-dom.development.js:21636:1)
    at HTMLUnknownElement.callCallback (react-dom.development.js:4164:1)
    at Object.invokeGuardedCallbackDev (react-dom.development.js:4213:1)
    at invokeGuardedCallback (react-dom.development.js:4277:1)
    at beginWork$1 (react-dom.development.js:27451:1)

Suggestions were to use another npm link to link the library temporarily to the react version of the test project ... this wasn't successful at all.

0

There are 0 answers