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

React hooks not found #526

Closed
mikabytes opened this issue Nov 30, 2018 · 5 comments
Closed

React hooks not found #526

mikabytes opened this issue Nov 30, 2018 · 5 comments

Comments

@mikabytes
Copy link
Collaborator

mikabytes commented Nov 30, 2018

  const value = useContext(Context)

useContext doesn't get imported. If I use fixWord, it says No JS module to import for useContext

However when I add it manuallly all works just fine.

This is using React 16.7.0-alpha.2

@mikabytes
Copy link
Collaborator Author

mikabytes commented Nov 30, 2018

Confirmed that specifying them manually in config solves the issue.

.importjs.js

module.exports = {
  namedExports: {
    'react': ['useState', 'useEffect', 'useContext', 'useReducer', 'useCallback', 'useMemo', 'useRef', 'useImperativeMethods', 'useLayoutEffect']
  }
}

@iahu
Copy link

iahu commented Nov 3, 2020

can it just work as well, but not set the namedExports config ?

@mikabytes
Copy link
Collaborator Author

Well, not at the time when I created this issue. I have since stopped using React, so I don't know if it has been solved since then.

@mikabytes
Copy link
Collaborator Author

mikabytes commented Feb 3, 2024

This is still an issue with React 18.2 and ImportJS 5.1. It just can't determine that the react module exports those methods for some reason.

@mikabytes
Copy link
Collaborator Author

Pretty sure this is due to #344

Closing this in favor of keeping discussion over there.

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

No branches or pull requests

2 participants