Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 16 additions & 10 deletions src/components/ReactMeteorData.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,7 @@ import Data from '../Data';
import MeteorDataManager from './MeteorDataManager';

const ReactMeteorData = {
UNSAFE_componentWillMount() {
Data.waitDdpReady(() => {
if (this.getMeteorData) {
this.data = {};
this._meteorDataManager = new MeteorDataManager(this);
const newData = this._meteorDataManager.calculateData();
this._meteorDataManager.updateData(newData);
}
});
},


UNSAFE_componentWillUpdate(nextProps, nextState) {
if (this.startMeteorSubscriptions) {
Expand Down Expand Up @@ -65,6 +56,7 @@ export { ReactMeteorData };

class ReactComponent extends React.Component {}
Object.assign(ReactComponent.prototype, ReactMeteorData);

class ReactPureComponent extends React.PureComponent {}
Object.assign(ReactPureComponent.prototype, ReactMeteorData);

Expand All @@ -81,9 +73,23 @@ export default function connect(options) {
const BaseComponent = pure ? ReactPureComponent : ReactComponent;
return WrappedComponent =>
class ReactMeteorDataComponent extends BaseComponent {
constructor(props) {
super(props);

Data.waitDdpReady(() => {
if (this.getMeteorData) {
this.data = {};
this._meteorDataManager = new MeteorDataManager(this);
const newData = this._meteorDataManager.calculateData();
this._meteorDataManager.updateData(newData);
}
});
}

getMeteorData() {
return getMeteorData(this.props);
}

render() {
return <WrappedComponent {...this.props} {...this.data} />;
}
Expand Down