this.state is null
222xiaohuan opened this issue · 7 comments
@Yomguithereal can you please help, thank you very much.
Same problem here
@222xiaohuan Change class SomeClass extends Component
to React.createClass
, still no sure exactly what is the difference or what is causing the problem, anyone has an idea?
Got it!
No Mixins Unfortunately ES6 launched without any mixin support. Therefore, there is no support for mixins when you use React with ES6 classes. Instead, we're working on making it easier to support such use cases without resorting to mixins.
https://facebook.github.io/react/docs/reusable-components.html#no-mixins
@psypersky so that means we can't use this baobab-react in ES6 environment?or is there any solutions? thank you so much~ 👍
Sure, use higher order components or decorators
https://github.com/Yomguithereal/baobab-react/blob/master/docs/higher-order.md
Im using decorators with the babel-plugin-transform-decorators-legacy
@branch({
chat: ['chat'],
})
export default class Chat extends React.Component {
static propTypes = {
chat: React.PropTypes.object.isRequired,
}...
@psypersky is right. If you want to use ES6 classes or pure function components, you can use the HOC or the decorators.