-
Notifications
You must be signed in to change notification settings - Fork 46.9k
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
[DevTools] Named hooks compatibility for create-react-app DEV mode #21868
Comments
Digging into this further and one thing I notice that seems unexpected is that the I can create a test app (using CRA) that has a file export function getError() {
return new Error();
} I can import and run the |
Below is the source code, compiled bundle, and source map. Source map is converting the
|
It looks like one way to "fix" this is to eject create-react-app: npm run eject Then modify |
Maybe I can relax DevTools to detect column == 0 case and do line-only mapping. It's probably not common for there to be more than one hook ID node per line anyway so maybe it's okay? This kind of pattern would break: const c = useContext(A), d = useContext(B); But maybe DevTools could account for that by detecting if there was more than one matching node for a given line and just giving up in that case? |
Something about the source maps config causes problems for a simple create-react-app running in DEV mode. Column numbers are always reported as 0 (by 'source-maps') which causes the AST node matching to fail so hook names can't be located. We should really fix this, since a lot of people use create-react-app for prototyping.
Note that source maps work correctly in production builds.
Repro: https://github.com/bvaughn/test-named-hooks
create-react-app bug report: facebook/create-react-app#11204
The text was updated successfully, but these errors were encountered: