bietkul / react-native-form-builder

Handle your forms in a smart way
MIT License
121 stars 68 forks source link

Fix for picker #17

Closed markterence closed 6 years ago

markterence commented 6 years ago

This is a fix for issue #16 and #12.

The code causes the error. picker/index.js#L27

Object.assign(styles.pickerMainAndroid, {
 backgroundColor: theme.pickerBgColor,
 borderBottomColor: theme.inputBorderColor,
 borderBottomWidth: theme.borderWidth,
})

I found two ways to prevent this error.

Error : You attempted to set the key backgroundcolor with the value "transparent"
on an object that is meant to be immutables and has been frozen.

A. Using Spread Operator (...) (This is what i used)

<View
  style={{...styles.pickerMainAndroid, ...{
    backgroundColor: theme.pickerBgColor,
    borderBottomColor: theme.inputBorderColor,
    borderBottomWidth: theme.borderWidth,
 }}}
>

B. Using Object.assign()

<View
 style={Object.assign({}, styles.pickerMainAndroid, {
   backgroundColor: theme.pickerBgColor,
   borderBottomColor: theme.inputBorderColor,
   borderBottomWidth: theme.borderWidth,
})}
>