Jerry
Jerry

Reputation: 1812

Is it necessary to wrap redux form field in a form tag?

I'm new to the redux form. I try to leverage the benefit it offers for one text input field in my react native app written in Typescript, literally just one text input field.

<Field name="payoutInput" type="text" component={this.renderPayout}/>

private renderPayout = (field: any) => (
    <View style={{flexDirection: "row", flex: 0.22, justifyContent: "flex-end"}}>
      <Text style={{fontSize: 17}}>
        $
      </Text>
      <TextInput style={{fontSize: 17}} defaultValue={String(this.props.balance)} autoFocus={true} keyboardType={'number-pad'} onEndEditing={this.calculatePayout}/>
    </View>
  )

What I notice is when I monitor the state in reactotron, I can't actually see the value in the form state. Using formValueSelector will also just give me undefined. So I'm wondering that if it's necessary to wrap the Field in a form?

Happy to provide more context on requested.

Upvotes: 0

Views: 177

Answers (1)

Dave Newton
Dave Newton

Reputation: 160191

Yes; that's how it connects inputs to the redux form state.

This is noted in the redux-form docs.

The redux-form docs note on React Native also says to follow this tutorial to get started, and neither resource indicates it works differently under React Native.

Upvotes: 1

Related Questions