0

My code for a component in React-Native is as follows (please note I am using native-base in case the structure looks weird):

class CardIntInput extends React.Component {

  render() {
    return (
      <Card>
        <Form>
          <Item regular>
            <Label> 
              {this.props.info}:
            </Label>
            <Input
              keyboardType = 'number-pad'
              onChangeText = {(text) => {this.props.data} = text}
            />
          </Item>
        </Form>
      </Card>
    )
  }
}

Every time I run the code it returns the aforementioned error, which I have isolated to the onChangeText line.

I am pretty new to JS and React Native and I've tried all that I can think of, so I turning to the advice of others.

I hope I'm just forgetting something simple but any advice would be much appreciated

anishp16
  • 3
  • 3

2 Answers2

0

The following will not issue an error:

onChangeText = {(text) => { this.props.data.text = text }}

It is an anti-pattern, however, to assign props data... See:

Yossi
  • 5,577
  • 7
  • 41
  • 76
0

When using typescript if you have named a component file .ts instead of .tsx this will raise a typescript error. Rename your file to .tsx

Robel Robel Lingstuyl
  • 1,341
  • 1
  • 11
  • 28