google-map-react/develop/utils/stream2Props.js
Michael Diego d457d1cd29
Fix recompose (#547)
* Create our own createHelper, its not in recompose anymore

* Use our withStateSelector

* Proper apiKey usage

* Replace apiKey with bootstrapUrlKeys

* No need of true value in html

* Use lodash.omit instead in dev

* Remove unused file

* Remove unnecessary extra folder utils

* Upgrade recompose again

* Oops! Move lodash.omit to devDependencies

* Fix webpack files styles

* Make examples bigger in width
2018-03-21 16:54:15 -07:00

32 lines
796 B
JavaScript

import { Component } from 'react';
import createHelper from './createHelper';
import createEagerFactory from './createEagerFactory';
// if stream prop will change this will fail,
// this is expected behavior
const stream2Props = props2Stream =>
BaseComponent => {
const factory = createEagerFactory(BaseComponent);
return class extends Component {
state = {};
componentWillMount() {
this.subscription = props2Stream(this.props).subscribe(value =>
this.setState({ value }));
}
componentWillUnmount() {
this.subscription.unsubscribe();
}
render() {
return factory({
...this.props,
...this.state.value,
});
}
};
};
export default createHelper(stream2Props, 'stream2Props');