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

useIntersectionObserver unexpected token #93

Closed
jeanlucmongrain opened this issue Jan 25, 2022 · 4 comments
Closed

useIntersectionObserver unexpected token #93

jeanlucmongrain opened this issue Jan 25, 2022 · 4 comments

Comments

@jeanlucmongrain
Copy link

I'm running 2.0.2 just fine and when I upgrad eto 2.2.2:

./node_modules/usehooks-ts/dist/esm/useIntersectionObserver/useIntersectionObserver.js 11:23
Module parse failed: Unexpected token (11:23)
File was processed with these loaders:
 * ./node_modules/react-scripts/node_modules/babel-loader/lib/index.js
You may need an additional loader to handle the result of these loaders.
|   } = _ref;
|   const [entry, setEntry] = useState();
>   const frozen = entry?.isIntersecting && freezeOnceVisible;
| 
|   const updateEntry = _ref2 => {
@jeanlucmongrain
Copy link
Author

rm -rf node_modules fixed that

@juliencrn
Copy link
Owner

Thanks @jeanlucmongrain :)

@arusak
Copy link

arusak commented Feb 8, 2022

I use react-scripts@4.0.3 and have the same error message. Removing node_modules didn't work for me.
I've done a bit of investigation, and found a few solutions.

  1. Update react-scripts to version 5.
  2. Downgrade usehooks-ts to version 2.1.1
  3. Add babel plugins proposal-optional-chaining and proposal-nullish-coalescing-operator into your babel config.

I use craco to tune my build, here's the config to satisfy babel:

module.exports = {
  babel: {
    // need this for usehooks-ts with react-scripts@4
    plugins: [
      ['@babel/plugin-proposal-optional-chaining'],
      ['@babel/plugin-proposal-nullish-coalescing-operator'],
    ],
  }
}

@juliencrn
Copy link
Owner

Thanks @arusak!

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

No branches or pull requests

3 participants