收到指出this.props.OnpPlaceAdded的错误不是函数

时间:2019-05-29 15:00:35

标签: javascript reactjs react-native

我是新来的人,正在学习一个教程,但是我目前对此仍然停留,无法前进。

我看过其他与我有关的问题,但没有一个答案能解决我的问题

class PlaceInput extends Component {
    state = {
        placeName: ""
    };
    placeNameChangedHandler = val => {
        this.setState({
            placeName: val
        });
    };
    placeSubmitHandler = () =>{
        if (this.state.placeName.trim() === ""){
            return;
        }

        this.props.OnPlaceAdded(this.state.placeName);
    };
    render() {
        return (
                <View style={styles.inputContainer}>
                    <TextInput
                        placeholder={"An awesome placeholder"}
                        value={this.state.placeName}
                        onChangeText={this.placeNameChangedHandler}
                        style={styles.placeInput}
                    />
                    <Button
                        title="Add"
                        style={styles.placeButton}
                        onPress={this.placeSubmitHandler}
                    />
                </View>
        );
    }
}

错误指出this.props.OnPlaceAdded不是函数。 (在“ _this.props.OnplaceAdded(_this.state.PlaceName)”中,“ _ this.props.OnPlaceAdded”未定义)

0 个答案:

没有答案