deavial / react-native-dialogbox

Dialog boxes for React Native (forked from react-native-popup)
Other
48 stars 21 forks source link

fix wrong loop for object keys #60

Closed rad182 closed 7 years ago

rad182 commented 7 years ago

This fixes style override because it's getting wrong keys

deavial commented 7 years ago

Could you elaborate. The code as-is enumerates the key names and assigns the value. of would bring back the value of the key, not the name unless there is an iterator symbol defined overriding that behavior.

rad182 commented 7 years ago

when I try to override the style like this

<DialogBox
          ref={dialogbox => {
            this.dialogbox = dialogbox;
          }}
          isOverlayClickClose={false}
          style={{
            tipTitle: {
              fontFamily: fonts.lato.semibold,
              fontSize: 17
            },
            tipContent: {
              fontFamily: fonts.lato.regular,
              fontSize: 14,
              color: '#676C71',
              paddingLeft: 20,
              paddingRight: 20,
              textAlign: 'center'
            }
          }}
        />

The name variable was getting 0 and 1 not sure why. or maybe this is not the way to override the style?

deavial commented 7 years ago

grr. you are correct! it is because Object.keys is returning an array. The code as it is written should have been

for (const name in override) { ... }

The Object.keys way normally would be:

Object.keys(override).forEach(name => {...})

and the token iterator (of) works similar to the forEach.

I will merge the change and publish a release.

Thanks for finding that!

deavial commented 7 years ago

it has been published to npm