react hooks not using data transformer
See original GitHub issueI’ve setup my react project according to the docs, but when I use the hooks, it doesn’t seem to use the data transformer.
Here is my trpc setup
import type { Router } from '..'
import superjson from 'superjson'
export const trpc = createReactQueryHooks<Router>()
export const trpcClient = trpc.createClient({
url: 'http://localhost:8080',
transformer: superjson,
headers: () => ({ Authorization: getAuthHeader() }),
})
export const queryClient = new QueryClient({
defaultOptions: {
queries: { refetchOnWindowFocus: false, retry: false, refetchOnMount: false },
mutations: { retry: false },
},
})
ReactDOM.render(
<React.StrictMode>
<trpc.Provider client={trpcClient} queryClient={queryClient}>
<QueryClientProvider client={queryClient}>
<App />
</QueryClientProvider>
</trpc.Provider>
</React.StrictMode>,
document.getElementById('root')
)
And this is how I am using the hooks inside the
const AppHeader: React.FC = () => {
const { data: school, isLoading } = trpc.useQuery([
'school.get',
{ id: schoolId }, //schoolId is a bigint here
])
return <></>
}
And i’m getting this error Uncaught TypeError: BigInt value can't be serialized in JSON
which shouldn’t happen if the transformer was being called.
Issue Analytics
- State:
- Created a year ago
- Comments:8 (5 by maintainers)
Top Results From Across the Web
Not able to see output of state using react hooks (useState ...
I am able to see the data in console log but nothing seems to be happening when i try to set it to...
Read more >Loading and Displaying Data with Hooks
In the third article we'll see how to share data between components with React Context without using globals, singletons or resorting to state ......
Read more >How to Fetch Data From an API Using React Hooks
In this article, we will look at how to fetch data from API using React hooks and also how to use the data...
Read more >Centralizing state and data handling with React Hooks - Algolia
How to use React Hooks to manage state and data, creating reusable UI components that maintain state information within each component.
Read more >Using the Effect Hook - React
Hooks are a new addition in React 16.8. They let you use state and other React features without writing a class. The Effect...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
just put this together sandbox
Excellent @sachinraja! So to be clear the solution is as follows (tested):