chore(xo-web): addSubscriptions provide initial props (#2697)

This commit is contained in:
Julien Fontanet 2018-02-28 16:09:56 +01:00 committed by GitHub
parent b499d60130
commit e25d6b712d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -7,6 +7,16 @@ const call = fn => fn()
// callbacks have been correctly initialized when there are circular dependencies // callbacks have been correctly initialized when there are circular dependencies
const addSubscriptions = subscriptions => Component => const addSubscriptions = subscriptions => Component =>
class SubscriptionWrapper extends React.PureComponent { class SubscriptionWrapper extends React.PureComponent {
constructor () {
super()
// provide all props since the beginning (better behavior with Freactal)
const state = (this.state = {})
Object.keys(subscriptions).forEach(key => {
state[key] = undefined
})
}
_unsubscribes = null _unsubscribes = null
componentWillMount () { componentWillMount () {