Nativebase: Drawer content color keep dark

Created on 28 Sep 2018  路  9Comments  路  Source: GeekyAnts/NativeBase

import React from 'react';
import { Container, Drawer, Button, Icon, Content, Text } from 'native-base';

export default class App extends React.Component {
  static navigationOptions = {
    header: null,
  };
  closeDrawer = () => {
    this.drawer._root.close()
  };
  openDrawer = () => {
    this.drawer._root.open()
  };

  render() {
    return (
      <Drawer
        ref={(ref) => { this.drawer = ref; }}
        content={<Content style={{ backgroundColor: '#FFFFFF' }}>
          <Text>Drawer</Text>
        </Content>}>
              <Button onPress={() => this.openDrawer()} transparent>
              <Icon name='menu' />
            </Button>
      </Drawer>
    )
  }
}

screen shot 2018-09-28 at 4 47 46 pm

Expect result: Drawer content is light and white color.

Most helpful comment

Managed to fix this issue by digging into the default properties of the Drawer component, by default the Drawer component's overlay has an elevation property of 8.

The elevation prop only effects Android (which is why this problem is not present in iOS) - to change the default props you can do this:

import { Drawer } from 'native-base';
...
Drawer.defaultProps.styles.mainOverlay.elevation = 0;

or wait until the above PR is merged (:

All 9 comments

exact same issue here! any answer please...

I still have the same problem, try zIndex and it does not work either, the only thing I could change is the type to displace

Node: 8.12.0
Mac OS: Mojave
react-native: 0.57.1
native-base: ^2.8.0

Same issue here!

native-base: ^2.8.0,
react-native: 0.57.1

The same issue here :/
react-native: 0.57.0,
native-base: 2.8.0

Same isse here.
react-native: 0.57.0,
native-base: "^2.8.0

Same as well
react-native: 0.57.1,
native-base: "^2.8.1

Managed to fix this issue by digging into the default properties of the Drawer component, by default the Drawer component's overlay has an elevation property of 8.

The elevation prop only effects Android (which is why this problem is not present in iOS) - to change the default props you can do this:

import { Drawer } from 'native-base';
...
Drawer.defaultProps.styles.mainOverlay.elevation = 0;

or wait until the above PR is merged (:

@suishum when I try that workaround I get:

You attempted to set the key `elevation` with the value `0` on an object that is meant to be immutable and has been frozen.

throwOnImmutableMutation
`deepFreezeAndThrowOnMutationInDev.js:71:4

etc.

My editor also underlines defaultProps in red, saying "Property 'defaultProps' does not exist on type 'typeof Drawer'." (But then, it also says property _root doesn't exist on drawer, and yet my open and close methods work just fine, so that's easy enough to ignore.)

However, adding styles={{mainOverlay: 0}} to the Drawer's props worked just fine.

@suishum when I try that workaround I get:

You attempted to set the key elevation with the value 0 on an object that is meant to be immutable and has been frozen.

throwOnImmutableMutation
`deepFreezeAndThrowOnMutationInDev.js:71:4

etc.

My editor also underlines defaultProps in red, saying "Property 'defaultProps' does not exist on type 'typeof Drawer'." (But then, it also says property _root doesn't exist on drawer, and yet my open and close methods work just fine, so that's easy enough to ignore.)

However, adding styles={{mainOverlay: 0}} to the Drawer's props worked just fine.

@jimcullenaus The error u mentioned appeared to me second time the view was rendered.
adding below code fixed the problem

if (Drawer.defaultProps.styles.mainOverlay.elevation != 0)
Drawer.defaultProps.styles.mainOverlay.elevation = 0;

Was this page helpful?
0 / 5 - 0 ratings

Related issues

inv2004 picture inv2004  路  3Comments

kitsune7 picture kitsune7  路  3Comments

chetnadaffodil picture chetnadaffodil  路  3Comments

muthuraman007 picture muthuraman007  路  3Comments

nschurmann picture nschurmann  路  3Comments