esbenp / react-native-clean-form

Easy react-native forms using bootstrap-like syntax with redux-form+immutablejs integration. Styled using styled-components
http://esbenp.github.io/2017/01/06/react-native-redux-form-immutable-styled-components/
MIT License
478 stars 76 forks source link

Prop `submitting` on `Button` not work if don't have prop `icon`. #43

Closed giautm closed 7 years ago

giautm commented 7 years ago

I think this is a bug. Because what i except is: loading will show if submitting == true.

markusguenther commented 7 years ago

The submitting state will work but you will not have the visual action. The reason for that is the condition within the button component.

if (icon) {
    const IconComponent = submitting
      ? <ActivityIndicator size="small" key="icon" color={theme.Button.color} />
      : <Icon key="icon" name={icon} size={14} color={theme.Button.color} />

    const prop = iconPlacement === 'left'
      ? 'marginRight'
      : 'marginLeft'

    IconWrapped = React.createElement(View, {
      children: IconComponent,
      style: {
        [prop]: 5
      }
    })
  }

So you only get the load indicator if you have the icon property.

giautm commented 7 years ago

I want to get the load indicator if i don't have the icon property. So, can we change to this?

if (submitting || icon) {
    const IconComponent = submitting
      ? <ActivityIndicator size="small" key="icon" color={theme.Button.color} />
      : <Icon key="icon" name={icon} size={14} color={theme.Button.color} />

    const prop = iconPlacement === 'left'
      ? 'marginRight'
      : 'marginLeft'

    IconWrapped = React.createElement(View, {
      children: IconComponent,
      style: {
        [prop]: 5
      }
    })
  }