meteor / react-packages

Meteor packages for a great React developer experience
http://guide.meteor.com/react.html
Other
574 stars 159 forks source link

createContainer != withTracker it seems #253

Closed tomachinz closed 6 years ago

tomachinz commented 6 years ago

I seem to have found a case where swapping createContainer for withTracker breaks.

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: 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 intense looking exception error reported via my logging system. This is trying to bring up the oauth buttons that have always worked fine and actually I hadn't touched since last year.

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)?

klaussner commented 6 years ago

You are not destructuring the argument (which is a props object and contains the services key) in the "new syntax" line. Try export default withTracker(({ services }) => { …. 🙂