Convert to withTracker

I have this code copied from orionsoft:react-meteor-data and used it in my app.

import { createContainer } from "meteor/react-meteor-data";

export default function(getMeteorData, opts) {
  return function(ComposedComponent) {
    return createContainer(
      Object.assign({ getMeteorData }, opts),
      ComposedComponent
    );
  };
}

How can I convert this to using withTracker?

Convert this part

import { createContainer } from "meteor/react-meteor-data";

...

createContainer(
  Object.assign({ getMeteorData }, opts),
  ComposedComponent
);

to

import { withTracker } from "meteor/react-meteor-data";

...

withTracker(Object.assign({ getMeteorData }, opts))(ComposedComponent);

As you see, the signature has just slightly changed.

1 Like

I am sure I did what you answered but been having some error when I ran it… But now that I cut and paste your solution the error I encountered was gone… Anyhow, thank you very much =)…

I am now totally a believer of the power of the Copy&Paste :smile:

1 Like

Yow! I remember what I did now…

export default function(getMeteorData, opts) {
  return function(ComposedComponent) {
   return withTracker(
       Object.assign({ getMeteorData }, opts)(ComposedComponent)
    );
 };
}

I was just about to point out the nesting and amount of parens involved you have going on in there :wink:

Good thing I’m copy&paste-friendly :wink: Not cut&paste though, that would be unfair and technically harder :smiley:

1 Like

now I edited my reply hahahahha lol

1 Like