Galooshi / import-js

A tool to simplify importing JS modules
MIT License
526 stars 70 forks source link

React hooks not found #526

Closed mikabytes closed 7 months ago

mikabytes commented 5 years ago
  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 commented 5 years ago

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 commented 3 years ago

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

mikabytes commented 3 years ago

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 commented 7 months ago

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 commented 7 months ago

Pretty sure this is due to #344

Closing this in favor of keeping discussion over there.