Closed Navyroot closed 4 years ago
Hi @Navyroot. withTracker passes your reactive data as properties to your components. Meteor recently added a hook called useTracker
, but we haven't finished adding this to meteor-react-native yet. However, you can still use withTracker even with function components:
import Meteor, {withTracker} from 'meteor-react-native';
const MyComponentInner = props => {
let {currentUser} = props;
// ...
}
const MyComponent = withTracker(() => {
return {
currentUser:Meteor.user()
};
})(MyComponentInner);
@TheRealNate thank you
+1
Hi @thearabbit, this question has been resolved since withTracker
resolved the author's issue. Are you interested in useTracker
? In that case, you can check out PR #17.
Sorry, thanks for your reply.
I would like to use useTracker
, because want to use dynamic subscript with dynamic params?
@thearabbit, have a look at PR #17 and let me know if it suits your needs. If there is something missing feel free to open a new issue. If you use PR #17 and it works well, please add a comment there letting us know so we can move closer to merging it.
Have any example to use? I will try to test
@thearabbit I believe based on the PR you can use it like this:
import Meteor, {useTracker} from '@meteorrn/core';
const MyComponent = () => {
let myData = useTracker(() => {
let user = Meteor.user();
return {user};
});
return <View>...</View>
}
Note that to install the repository from the PR, you should be able to use this command:
npm install --save https://github.com/sandeepjain/meteor-react-native.git
I would not recommend using the PR for production, as it won't receive updates, but if you could test it out per your use-case and let me know if it works well I can finish the review and merge the PR.
Thanks I will try soon.
Hi @thearabbit, any updates?
could you explain me how to use
withTracker
with reack hooks ?