meteor / react-packages

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

Audit argument check error when using useSubscribe #358

Closed StorytellerCZ closed 2 years ago

StorytellerCZ commented 2 years ago

I have this publication:

Meteor.publish('profile', function () {
  return ProfilesCollection.find(
    { _id: this.userId },
    {
      limit: 1
    }
  )
})

And then I'm getting the data via:

const isLoading = useSubscribe('profile', [user._id])
  const profile = useTracker(
    () => ProfilesCollection.findOne(user._id),
    [isLoading()]
  )

Which triggers the Error: Did not check() all arguments during publisher 'profile' from audit-argument-checks

If I revert the subscribe function back to:

const isLoading = useTracker(
    () => Meteor.subscribe('profile').ready(),
    [user._id]
  )

Then the error goes away.

CaptainN commented 2 years ago

There's code missing here. How did you get from this.user to user._id? That detail may be relevant.

henriquealbert commented 2 years ago

@StorytellerCZ, would you be able to provide the code that @CaptainN asked for? So we can dig deeper into that. Thanks.

StorytellerCZ commented 2 years ago

The user comes from const user = useUser()

CaptainN commented 2 years ago

I think this issue here is that useSubscribe does not require or accept deps. Remove that, and you should be good to go.

(It's giving you a warning about checking your arguments, because your deps array is being passed to the publication, which is neither expecting nor checking that argument.)

StorytellerCZ commented 2 years ago

Looks like that might have been it.