-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
[babel-plugin] ViewLayoutEvent type not exported as per react-native #822
Comments
This may also affect |
Having looked a little into this, the problem seems to be that the babel-plugin-react-native-web uses the import name to determine which exports file to load. Because ViewLayoutEvent is inside ViewPropTypes, it fails. This is why the error message contains It seems the exports are correctly stated, its the module mapping between RN and RNW that gets it wrong. I've also found that import { View } from 'react-native'
//...
handleLayout = (e: View.ViewLayoutEvent) => {
//...
}
//... |
If it's a type shouldn't you be importing it as a type rather than a module? |
I tried the 'type' keyword but this didn't make any difference. There is a definite weakness in the Babel plugin in how it tries to locate the export module based on the import name, which is what generates the error message. I'm happy for this issue to be closed and a new one created to document the plugin weakness. |
Please can you try disabling the babel plugin in development. Babel is meant to remove flow types so I'm thinking the import rewrites won't matter for production builds. |
Sorry, but I don't understand what you mean by that. If I remove the babel-plugin-react-native-web plugin from my webpack config, its just hurls a ton of errors about missing modules. Am I supposed to replace the plugin with another way of resolving? |
Remove the plugin in development and do the |
@necolas Thanks for the clarification. I don't have time right now and have a workaround. I'll try and come back to it. |
I've just updated to RNW 0.4, just realised I was not on latest. I'm guessing that you have another release coming up as you've made commits today etc. Problem still exists, but it seems that its temperamental regarding which plugins its installed alongside. My webpack config has changed since I opened the issue, best thing would be to look in the repo: https://github.com/dmeehan1968/react-native-web-sketch-boilerplate Webpack config is in As it stands, the code is running as I used a workaround listed above to get at the ViewLayoutEvent type. To trigger the problem, modify import { Animated, PanResponder, View, StyleSheet } from 'react-native' to import { Animated, PanResponder, View, StyleSheet, ViewLayoutEvent } from 'react-native' Then run Don't worry that its not used, the import is enough to trigger the bug. |
Do you want to request a feature or report a bug?
Bug
What is the current behavior?
NB: Using Flow for type checking.
ViewLayoutEvent
not accessible as a named export from RNW in the same was as from RN.ViewLayoutEvent
is required for correct parameter typing of theonLayout
handler passed toView
components.What is the expected behavior?
The following line works in RN, but not in RNW
This produces the following error:
A workaround is to use a import on all of RN, then reference the type.
Environment (include versions). Did this work in previous versions?
Untested in previous versions.
webpack.config.js
The text was updated successfully, but these errors were encountered: