import { polyfillGlobal } from "react-native/Libraries/Utilities/PolyfillFunctions"const applyGlobalPolyfills = () => { const { TextEncoder, TextDecoder } = require("text-encoding") polyfillGlobal("TextEncoder", () => TextEncoder) polyfillGlobal("TextDecoder", () => TextDecoder)}export default applyGlobalPolyfills
// calling this applyGlobalPolyfills()
const user = useAppUser(); const [activitity, setActivity] = useState(); const [skip, setSkip] = useState(0); const limit = 20; const today = new Date(); const { data: challenges, isLoading, refetch, isRefetching } = api.challenges.list.useQuery( user ? { limit: 50, skip, id: user.id, startDate: today, ...(activitity ? { activities: [activitity] } : {}) } : null, // Only make the request if user is available { enabled: !!user, trpc: { abortOnUnmount: true, }} // Ensure the query is enabled only when user is available );