jsonapi-react
jsonapi-react copied to clipboard
Getting cannot read properties of undefined (reading 'ssrMode')

Getting this error from couple of days , tried enough but doesn't get any possible solution.
Hi @bhavesh1334,
It looks like the library could employ some better exception handling here, but the issue on your side appears to be that you are attempting to use useQuery outside the ApiProvider context.
Restructuring your code in the following manner should do the trick:
function App(props) {
const query = useQuery('posts')
return (
<div>
<h1>Hello</h1>
</div>
)
}
const root = (
<ApiProvider client={client}>
<App />
</ApiProvider>
)
React.render(root, document.getElementById('root'))