mirror of
https://github.com/google-map-react/google-map-react.git
synced 2025-12-08 18:26:32 +00:00
* Run eslint * Avoid DRY in importing * Update recompose * Unnecessary backticks * Update comments * Move api-path into a variable * Rename queryString to params * Proper eslint-disable
32 lines
795 B
JavaScript
32 lines
795 B
JavaScript
import { Component } from 'react';
|
|
import { createHelper } from 'recompose';
|
|
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');
|