Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[templates/nextjs] Fix monorepo sample failing on client #1639

Merged
merged 1 commit into from
Oct 26, 2023

Conversation

art-alexeyenko
Copy link
Contributor

@art-alexeyenko art-alexeyenko commented Oct 25, 2023

Description / Motivation

Monorepo was failing with 'useContext' error (cannot read properties of null). This PR should fix it.

Testing Details

  • Unit Test Added
  • Manual Test/Other (Please elaborate)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

@art-alexeyenko art-alexeyenko requested a review from a team October 25, 2023 20:34
Copy link
Contributor

@illiakovalenko illiakovalenko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@illiakovalenko illiakovalenko merged commit f4095e0 into dev Oct 26, 2023
2 checks passed
@illiakovalenko illiakovalenko deleted the bug/jss-865-sample-fails-monorepo branch October 26, 2023 11:50
@jflheureux
Copy link
Contributor

When starting a new project on the latest xmcloud-foundation-head (with JSS 21.6.0), the first thing my team did was to install the latest version of Storybook (7.6.10). Installation went well but no component showing in Storybook and we got browser console errors:

Warning: 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 https://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem.

Uncaught TypeError: Cannot read properties of null (reading 'useRef')
    at useRef (react.development.js:1630:1)
    at WithCallback (react-18.mjs:4:1)
    at renderWithHooks (react-dom.development.js:10732:1)
    at mountIndeterminateComponent (react-dom.development.js:15770:1)
    at beginWork$1 (react-dom.development.js:17354:1)
    at HTMLUnknownElement.callCallback (react-dom.development.js:19467:1)
    at Object.invokeGuardedCallbackImpl (react-dom.development.js:19516:1)
    at invokeGuardedCallback (react-dom.development.js:19591:1)
    at beginWork (react-dom.development.js:25733:1)
    at performUnitOfWork (react-dom.development.js:24557:1)

After comparing the xmcloud-foundation-head repo with its previous version using JSS 21.5.X, we identified the change that breaks Storybook is the change from this pull request.

Reverting this change in our project resolved the Storybook issues. All we had to do was to revert the compilerOptions.paths.react to ["node_modules/@types/react"] in the tsconfig.json file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants