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

DrawerLayoutAndroid:- undefined is not an object (evaluating DrawerLayoutAndroid.positions ) #3031

Closed
kishanj918 opened this issue Sep 25, 2015 · 15 comments
Labels
Resolution: Locked This issue was locked by the bot.

Comments

@kishanj918
Copy link

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);
@NishanthShankar
Copy link

Try using
DrawerLayoutAndroid = require('DrawerLayoutAndroid');
Most Android modules have to be imported this way. I'm not sure why

@kishanj918
Copy link
Author

@NishanthShankar Thanks. That worked!

@brentvatne
Copy link
Collaborator

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.

@brentvatne brentvatne reopened this Sep 25, 2015
@brentvatne
Copy link
Collaborator

Confirmed that this is not happening: https://rnplay.org/apps/XDP9Tg

Please make sure you're using DrawerLayoutAndroid correctly :)

@chourobin
Copy link
Contributor

Encountering the same issues. Only var DrawerLayoutAndroid = require('DrawerLayoutAndroid'); works.

@brentvatne
Copy link
Collaborator

@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?

@chourobin
Copy link
Contributor

@brentvatne sorry I spoke too soon, I do run into issues with the copy pasted code in a fresh project.

@brentvatne
Copy link
Collaborator

@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!

@chourobin
Copy link
Contributor

@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'.

@Tjorriemorrie
Copy link

Also having this issue from AwesomeProject, only works if drawer is required.

@brentvatne brentvatne reopened this Sep 27, 2015
@Tjorriemorrie
Copy link

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)

screen shot 2015-09-27 at 20 44 34

@brentvatne What information do you need?

@Tjorriemorrie
Copy link

Yes, it works if I revert back to 0.11.0. Don't you use deployment tests?

@ide
Copy link
Contributor

ide commented Sep 28, 2015

Android is currently not tested in the open-source repo.

@brentvatne
Copy link
Collaborator

Android is tested now, this should work!

@facebook facebook locked as resolved and limited conversation to collaborators Jul 21, 2018
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Jul 21, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

7 participants