meteorrn / meteor-react-native

Meteor client for React Native matching Meteor Spec
https://guide.meteor.com/react-native.html
Other
59 stars 31 forks source link

Getting error while using useTracker hook #60

Closed rajtejani closed 3 years ago

rajtejani commented 3 years ago

Describe the bug I have installed 2.1.0 and tried to use useTracker hook but it gives me an error that _core.useTracker is not a. function. I am trying to use this hook inside the function component.

Screenshots simulator_screenshot_11FD8C81-CF09-4EBE-A02B-F78544CD66F6

Device (please complete the following information):

TheRealNate commented 3 years ago

Hi @rajtejani, how are you defining the useTracker variable? useTracker is a property of Meteor, so needs to be used like this:

import Meteor from '@meteorrn.core';

...

Meteor.useTracker(() => {
})

or this:

import Meteor from '@meteorrn.core';
const { useTracker } = Meteor;

...

useTracker(() => {
})

Are you using the second option?

rajtejani commented 3 years ago

Thanks @TheRealNate . I was actually importing like this 😅 import {useTracker} from '@meteorrn/core'.

Your both way is working fine. Thanks for the help again.