Failed prop type: Invalid prop 'value'

Abdallah Sabri

Whenever I try o type into the TextInput I keep getting this warning: failed prop type invalid prop 'value' of type 'object' supplied to 'textinput' expected 'string'

LoginForm.js

import React, { Component } from 'react';
import { Card, CardSection, Button, Input } from './common';

class LoginForm extends Component {

    state = { email: '', password: '', error: '' };

    render() {
        return (
            <Card>
                <CardSection>
                    <Input 
                    label='Email'
                    placeholder='[email protected]'
                    value={this.state.email}
                    onChangeText={(email) => this.setState({ email: email } )}
                    />
                </CardSection>

Input.js

import React from 'react';
import { TextInput, View, Text } from 'react-native';

const Input = ({ label, value, onChangeText, placeholder, secureTextEntry }) => {
    return (
        <View style={styles.containerStyle}>
            <Text style={styles.labelStyle}>{ label }</Text>
                <TextInput
                secureTextEntry={secureTextEntry}
                placeholder={placeholder}
                style={styles.inputStyle}
                value={value}
                onChange={onChangeText}
                autoCorrect={false}
                />
        </View>
    );
};

Could you please help me to find the problem?

Hend El-Sahli

The event listener you need to bind is onChangeText

onChangeText expects a string param ... where onChange expects an object of this form: nativeEvent: { eventCount, target, text} ... that's why you're getting this error...

<Text style={styles.labelStyle}>{ label }</Text>
                <TextInput
                secureTextEntry={secureTextEntry}
                placeholder={placeholder}
                style={styles.inputStyle}
                value={value}
                onChangeText={onChangeText} // <--Look at this
                autoCorrect={false}
                />

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Failed prop type: Invalid prop `value` of type `number`

Failed prop type: Invalid prop `to` supplied to `Redirect`

Failed prop type: Invalid prop 'value' of type 'object' supplied to 'TextInput' React Native

Warning: Failed prop type: Invalid prop `value` of type `number` supplied to `TextInput`, expected `string`

[Vue warn]: Invalid prop: type check failed for prop "page". Expected Number with value 0, got String with value ""

Invalid prop: type check failed for prop "value". Expected Boolean, got String with value "0"

Failed prop type: Invalid prop `children` of type `array` supplied to `GlobalState`

Failed prop type: Invalid prop `opacity` of type `object` supplied to `RCTView`

React Warning: Failed prop type: Invalid prop of type `Object` supplied

Failed prop type: Invalid prop `className` of type 'function'

Failed prop type: Invalid prop `preferences[19].category` of value `MemberBenefitInterests` supplied to `SettingsPage`

Invalid prop: type check failed for prop "cellClass". Expected String with value "[object Object]", got Object

Vuejs error, Invalid prop: type check failed for prop. Expected Date, got Number with value

[Vue warn]: Invalid prop: type check failed for prop "productCartData". Expected Object, got String with value "[object Object]"

Failed prop type: Invalid prop `lg` supplied to `ForwardRef(Grid)`

Warning: Failed prop type: Invalid prop `tag` supplied to `NavLink`

Warning: Failed prop type: Invalid prop 'source' supplied to 'Image'

warning: failed prop type: invalid prop 'backgroundcolor' supplied to view:

laravel vue pagination return invalid prop type check failed for prop

Failed prop type The prop is marked as required but its value is `undefined`

ReactJS Failed Prop Type With 'undefined' Value

Invalid prop type supplied

Vue: Invalid prop: type

React Native error Failed prop type: Invalid prop `children` of type `array` supplied to `Overlay`,

Failed prop type: Invalid prop `match.params` of type `object` supplied to `Page`, expected `string`

Warning: Failed prop type: Invalid prop `data` of type `object` supplied to `Carousel`, expected `array`

Failed prop type: Invalid prop `onClick` of type `object` supplied to `ButtonBase`, expected `function`

Failed prop type: Invalid prop of type `function` supplied expected a single ReactElement

Failed prop type: Invalid prop `onClick` of type `object` supplied to `Button`, expected `function`