export default class Home extends Component {
state = {
loggedIn: Meteor.userId(), // check if user is logged in, initial state
};
render() {........
but soon realized it wasn’t reactive in finding if user was logged in - especially when I call ’ Meteor.logoutOtherClients();’
I know I’m supposed to use Tracker, but im not sure what the correct way of implementing it is? Do I put it in a componentDidMount() ? I would like to make the state reactive so I can show a particular page or not.
Thank you in advance
EDIT: Or should I get rid of the ‘export’ and instead put it inside (found from example):
Also, by convention react hooks are named useXxx() - this applies to the ones that ship with react (useState, useEffect…), and to custom ones you build on top of them.
withTracker() is more the name of a HOC, and useTracker() more the name of a hook.
Thank you for that. Just one quick question, though:
How would one use useTracker in case of no needed exterior dependencies on a prop? Like, for example, getting all users (with the proper publication server-side, of course!)? Would it look like this?
How is this situation in 2022? I’m currently using withTracker from @meteorrn/core
However, I’d love to use Hooks here as well, so is it possible to use the useTracker Hook in React Native same way as for usual web dev (from meteor/react-meteor-data)?