DrawerLayoutAndroid:- undefined is not an object (evaluating DrawerLayoutAndroid.positions )
I am using DrawerLayoutAndroid's example code.. Some how it's giving me above mentioned error...
var React = require('react-native');
var {
AppRegistry,
Text,
DrawerLayoutAndroid,
}= React
var AwesomeProject = React.createClass({
render: function () {
var navigationView = (
<Text style = {{margin: 10, fontSize: 15, textAlign: 'left'}}>I'm in the Drawer!</Text> );
return (<DrawerLayoutAndroid drawerWidth = {300} drawerPosition = {DrawerLayoutAndroid.positions.Left}
renderNavigationView = {() => navigationView}> <Text
style = {{margin: 10, fontSize: 15, textAlign: 'right'}}>Hello</Text> <Text
style = {{margin: 10, fontSize: 15, textAlign: 'right'}}>World!</Text> </DrawerLayoutAndroid> );
},
});
AppRegistry.registerComponent('AwesomeProject', () => AwesomeProject);
Try using
DrawerLayoutAndroid = require('DrawerLayoutAndroid');
Most Android modules have to be imported this way. I'm not sure why
@NishanthShankar Thanks. That worked!
You shouldn't use var DrawerLayoutAndroid = require('DrawerLayoutAndroid'); because that is an unsupported side-effect of how the packager works. See #1821
If you can't use DrawerLayoutAndroid like any other React Native component then that is a bug.
Confirmed that this is not happening: https://rnplay.org/apps/XDP9Tg
Please make sure you're using DrawerLayoutAndroid correctly :)
Oh.. But the examples use it as var AndoridComponent = require(AndoridComponent)
https://github.com/facebook/react-native/blob/master/Examples/UIExplorer/ToolbarAndroidExample.android.js
https://github.com/facebook/react-native/blob/master/Examples/UIExplorer/ProgressBarAndroidExample.android.js
Encountering the same issues. Only var DrawerLayoutAndroid = require('DrawerLayoutAndroid'); works.
@NishanthShankar - those are inside of the repo itself, that's a little bit confusing indeed.. Notice that throughout all of the codebase require('X') rather than require('../SomeDirectory/X') are used - this is because of how Facebook uses @providesModule internally.
@chourobin - if you copy the exact code from the above rnplay link I provided and run that locally, do you also get errors?
@brentvatne sorry I spoke too soon, I do run into issues with the copy pasted code in a fresh project.
@chourobin - with the exact code from the example? That's weird! Can you upload a repo with it and include the node_modules directory too? Thanks!
@brentvatne - Hey Brent, sure here it is: https://github.com/chourobin/AndroidDrawer. Fresh project, copy pasted code & renamed SampleApp -> AndroidDrawer. Unfortunately it only works when I explicitly include 'DrawerLayoutAndroid'.
Also having this issue from AwesomeProject, only works if drawer is required.
I can't duplicate it on that playground but I'm not sure if I'm seeing it either. Maybe this is a version issue. Used default nexus5 device config.
CPU/ABI: Intel Atom (x86)
Target: Android 6.0 (API level 23)
@brentvatne What information do you need?
Yes, it works if I revert back to 0.11.0. Don't you use deployment tests?
Android is currently not tested in the open-source repo.
Android is tested now, this should work!