createContainer versus withTracker

So I’ve been making an app with Pup by The Meteor Chef, its an awesome boilerplate with Meteor and React together.

For a while I’ve been seeing these messages in the browser due to use of createContainer:
createContainer.jsx: Warning: createContainer was deprecated in react-meteor-data@0.2.13. Use withTracker instead. See https://github.com/meteor/react-packages/tree/devel/packages/react-meteor-data#usage

So I go through and change a bunch of them over. But when I get to Login.js I can not change it as I see this error reported via my logging system.

The only thing I can think of is perhaps its caused by the comma after: services: verifiedServices.get(),
???

Stumped. Will have to keep using createContainer for now…

The only change was to swap the old syntax for the new syntax:

// export default createContainer(({ services }) => { // OLD SYNTAX
export default withTracker(services => { // NEW SYNTAX

if (!verificationComplete.get()) {
Meteor.call(‘oauth.verifyConfiguration’, services, (error, response) => {
if (error) {
console.warn(error);
} else {
verifiedServices.set(response);
verificationComplete.set(true);
}
});
}

return {
services: verifiedServices.get(),
};
// }, OAuthLoginButtons); // OLD SYNTAX
})(OAuthLoginButtons); // NEW SYNTAX

I20180406-01:51:32.218(12)? Exception while invoking method ‘oauth.verifyConfiguration’ Error: Match error: Expected Array
I20180406-01:51:32.218(12)? at exports.check (packages/check.js:55:15)
I20180406-01:51:32.218(12)? at DDPCommon.MethodInvocation.oauthVerifyConfiguration (imports/api/OAuth/server/methods.js:8:5)
I20180406-01:51:32.219(12)? at packages/check.js:128:16
I20180406-01:51:32.219(12)? at Meteor.EnvironmentVariable.EVp.withValue (packages/meteor.js:1186:15)
I20180406-01:51:32.219(12)? at Object._failIfArgumentsAreNotAllChecked (packages/check.js:127:41)
I20180406-01:51:32.219(12)? at maybeAuditArgumentChecks (packages/ddp-server/livedata_server.js:1765:18)
I20180406-01:51:32.219(12)? at DDP._CurrentMethodInvocation.withValue (packages/ddp-server/livedata_server.js:719:19)
I20180406-01:51:32.220(12)? at Meteor.EnvironmentVariable.EVp.withValue (packages/meteor.js:1186:15)
I20180406-01:51:32.220(12)? at DDPServer._CurrentWriteFence.withValue (packages/ddp-server/livedata_server.js:717:46)
I20180406-01:51:32.220(12)? at Meteor.EnvironmentVariable.EVp.withValue (packages/meteor.js:1186:15)
I20180406-01:51:32.220(12)? at Promise (packages/ddp-server/livedata_server.js:715:46)
I20180406-01:51:32.220(12)? at new Promise ()
I20180406-01:51:32.220(12)? at Session.method (packages/ddp-server/livedata_server.js:689:23)
I20180406-01:51:32.221(12)? at packages/ddp-server/livedata_server.js:559:43
I20180406-01:51:32.221(12)? Sanitized and reported to the client as: Match failed [400]
I20180406-01:51:32.221(12)?

1 Like

I believe this is your issue… This part hasn’t changed. The first param is still the props object that is passed from the parent component. You don’t necessarily have to use parameter destructuring, but you will need to destructure it at some point to pass the services key to Meteor.call

export default withTracker( params => {
    const { services } = params;

    if (!verificationComplete.get()) {
        Meteor.call(‘oauth.verifyConfiguration’, services, (error, response) => {
            if (error) {
                console.warn(error);
            } else {
                verifiedServices.set(response);
                verificationComplete.set(true);
            }
        });
    }

    return {
        services: verifiedServices.get(),
    };
})(OAuthLoginButtons);
2 Likes

Hey @tomachi thanks for using Pup. Just curious, is the createContainer usage here code that you’ve written or code that already existed in Pup? We updated from createContainer to withTracker around November last year, so latest versions should be correct per the package’s warning.

2 Likes

Thanks so much!! WORDS CAN NOT EXPRESS joy the code is working again beautifully. Destructuring, eh, will do some research on this… cheers

I used the “Invoicing App” template / working example from last year, and then went to town on it, never looked back, not sure how easy it is to keep it current (just one man band self teaching presently). With this destructing advice I should have no issues now.

1 Like