Failed prop type: Chat: prop type `room` is invalid; it must be a function, usually from React.PropTypes

whiteadi

this is the full code for the react component:

import React from 'react';

class Chat extends React.Component {
    handleSubmit(e) {
        e.preventDefault();

        this.props.addMessage(this.props.room.id, this.state.message);

        this.setState({ message: '' });
    }

    handleMsgChange(event) {
        this.setState({ message: event.target.value });
    }

    render() {
        return (
            <div>
                <div>{this.props.room.messages.toString()}</div>
                <form onSubmit={this.handleSubmit}>
                    <input
                        onChange={this.handleMsgChange}
                        value={this.state.message}
                        type="text" placeholder="Your message"
                    />
                    <input type="submit" value="Send" />
                </form>
            </div>
        );
    }
}

Chat.propTypes = {
    addMessage: React.PropTypes.func,
    room: React.PropTypes.Object,
};

export default Chat;

and I get the error:

Failed prop type: Chat: prop type room is invalid; it must be a function, usually from React.PropTypes.

Alexandr Lazarev

Change room: React.PropTypes.Object to room: React.PropTypes.object. You've made a typo, object property should start with o in lowercase.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Warning: Failed prop type: Game: prop type `game` is invalid; it must be a function, usually from React.PropTypes

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

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

React PropTypes import class. Prop type is invalid

React: Prop type must be a function, but received object

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

Failed prop type: Invalid prop 'value'

React Warning: "Failed prop type: checker is not a function"

it must be a function, usually from React.PropTypes

Invalid prop of type `string` in react

Invalid prop `function` of type `boolean`

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

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

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

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

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

React Snapshot testing with jest - Failed prop type: Invalid prop `children` of type `string` supplied

react-router-dom Failed prop type: Invalid prop `exact` of type `string`

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`

Warning: Failed prop type: Invalid prop `defaultValue` of type `string` supplied to `AutoCompleteSearch`, expected `function`

Failed prop type: Invalid prop `component` of type `object` supplied to `Route`, expected `function`

Warning: Failed prop type: Invalid prop `open` of type `function` supplied to `ForwardRef(Dialog)`, expected `boolean`. at Dialog

Warning: Failed propType: Invalid prop of type `array` expected `object` with React

Failed prop type: The prop justify of Grid must be used on container

React router error (Failed prop type: Invalid prop `children` supplied to `Switch`, expected a ReactNode.)

vue warning: Invalid prop: type check failed for prop "modalState". Expected Boolean, got Function

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