Uncaught TypeError: Cannot read property '_currentElement'
"react": "^0.14.8",
ES6
ReactCompositeComponent.js:559 Uncaught TypeError: Cannot read property '_currentElement' of null
render()の時にエラーになっているようだった。
constructorに
this.state = {error: false}
を足したらエラーが消えた。
import React, { Component, PropTypes } from 'react' import RaisedButton from 'material-ui/lib/raised-button'; import TextField from 'material-ui/lib/text-field'; const style = { margin: 12, }; export default class Login extends Component { constructor(props, context){ super(props); context.router // will work this.state = {error: false} } getInitialState() { return { error: false } } handleSubmit(event) { event.preventDefault() const email = this.refs.email.value const pass = this.refs.pass.value auth.login(email, pass, (loggedIn) => { if (!loggedIn) return this.setState({ error: true }) const { location } = this.props if (location.state && location.state.nextPathname) { this.context.router.replace(location.state.nextPathname) } else { this.context.router.replace('/') } }) } render() { return ( <form onSubmit={this.handleSubmit}> <label><input ref="email" placeholder="email" defaultValue="joe@example.com" /></label> <label><input ref="pass" placeholder="password" /></label> (hint: password1)<br /> <button type="submit">login</button> {this.state.error && ( <p>Bad login information</p> )} </form> ) } }