Closed lanphammmm closed 1 year ago
Hello @l4n2k1 I have an iPad here and could try to reproduce this. In order to reproduce I additionally need:
Hi @jankapunkt I have located it in AppNavigator.tsx
and used it normally. After a short time, it will heat up.
UserTracker.ts
const Meteor = meteorCore.getMeteorInstance()
let UserCollection = new Meteor.Mongo.Collection('user')
export const useUserTracker = () => {
const dispatch = useAppDispatch()
const subscribeRef = useRef<{ ready: () => boolean } | null>(null)
const userInfo = useAppSelector(getUserInfo)
const userSubscription = Meteor.useTracker(() => {
if (!subscribeRef.current) {
const subscriber = Meteor.subscribe('userInfo', String(userInfo?._id))
subscribeRef.current = subscriber
} else {
if (subscribeRef.current?.ready()) {
return UserCollection.find({
userInfo: userInfo?._id,
}).fetch()
}
}
})
useAppState((appState: AppStateStatus) => {
if (appState === 'background' || appState === 'inactive') {
subscribeRef.current = null
}
})
useUpdateEffect(() => {
if (!subscribeRef.current?.ready()) {
return
}
const isDiff = _.differenceWith(userSubscription, userInfo, _.isEqual)
if (isDiff) {
dispatch(updateUserInfo(userSubscription))
}
}, [userSubscription])
}
Navigator
const AppNavigator = () = {
useUserTracker()
return <View/>
}
const Navigation = () => {
return isLogin ? <AppNavigator /> : <AuthNavigator />
}
Document: https://guide.meteor.com/react-native.html#usage IOS version: iOS 16
@l4n2k1 I forgot to ask something more:
I checked and without using useTracker the phone is not as hot as before
What did you use instead of useTracker
then?
Hi @jankapunkt ja I don't use any substitute for it. I just turned it off
Closing this issue due to no activity. Feel free to reopen.
Descriptions I use
useTracker
to listening real-time data when the server update. But the phone heats up quickly when used for a short time (1-2 minutes). I checked and without usinguseTracker
the phone is not as hot as before. This only happens on iOS.Code
I hope to help me.