Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6290

react-native trpc always loading

$
0
0

I tried to use trpc with the fastify adapter and it works just fine; however, when I tried to use in in my react native app it does not work (it already woked with nextjs). It only displays loading as a status.

const getBaseUrl = () => {  const localhost = Constants.manifest?.debuggerHost?.split(":")[0];  if (!localhost)    throw new Error("failed to get localhost, configure it manually");  return `http://${localhost}:3000/trpc`;};export const TRPCProvider: React.FC<{ children: React.ReactNode }> = ({  children,}) => {  console.log(getBaseUrl())  const [queryClient] = useState(() => new QueryClient());  const [trpcClient] = useState(() =>    trpc.createClient({      links: [        httpBatchLink({          url: `${getBaseUrl()}`,        }),      ],    }),  );  return (<trpc.Provider client={trpcClient} queryClient={queryClient}><QueryClientProvider client={queryClient}>        {children}</QueryClientProvider></trpc.Provider>  );};export const TRPCProvider: React.FC<{ children: React.ReactNode }> = ({  children,}) => {  console.log(getBaseUrl())  const [queryClient] = useState(() => new QueryClient());  const [trpcClient] = useState(() =>    trpc.createClient({      links: [        httpBatchLink({          url: `${getBaseUrl()}`,        }),      ],    }),  );  return (<trpc.Provider client={trpcClient} queryClient={queryClient}><QueryClientProvider client={queryClient}>        {children}</QueryClientProvider></trpc.Provider>  );};

Viewing all articles
Browse latest Browse all 6290

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>