whiteadi whiteadi - 1 year ago 298
React JSX Question

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

this is the full code for the react component:

import React from 'react';

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

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

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

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

render() {
return (
<form onSubmit={this.handleSubmit}>
type="text" placeholder="Your message"
<input type="submit" value="Send" />

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

export default Chat;

and I get the error:

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

Answer Source

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download