Skip to content

Commit

Permalink
Downgrade react query from v5 to v4 (#500)
Browse files Browse the repository at this point in the history
* Remove sample-netflix from examples

* Fix downgrade react-query from v5 to v4
Some users are still in older versions of React like React 16 or 17. We
moved back to react-query@v4 because v5 was using `useAsyncExternalStore`. We want to be more backwards compatible
  • Loading branch information
andresgutgon authored Jun 7, 2024
1 parent dcb34c0 commit 0ce4ca7
Show file tree
Hide file tree
Showing 10 changed files with 774 additions and 434 deletions.
5 changes: 5 additions & 0 deletions .changeset/angry-planes-collect.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@latitude-data/react": patch
---

Make @latitude-data/react compatible with react 16 and 17
1 change: 0 additions & 1 deletion examples/sample-netflix
Submodule sample-netflix deleted from d0820e
5 changes: 5 additions & 0 deletions packages/client/react/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ module.exports = {
"plugin:react/recommended",
"plugin:react-hooks/recommended"
],
settings: {
react: {
version: "detect"
}
},
rules: {
"react/react-in-jsx-scope": "off",
"react/display-name": "off",
Expand Down
6 changes: 3 additions & 3 deletions packages/client/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"@radix-ui/react-label": "^2.0.2",
"@radix-ui/react-popover": "^1.0.7",
"@radix-ui/react-slot": "^1.0.2",
"@tanstack/react-query": "^5.28.14",
"@tanstack/react-query": "^4.35.3",
"@tanstack/react-table": "^8.16.0",
"class-variance-authority": "^0.7.0",
"echarts": "^5.5.0",
Expand All @@ -44,8 +44,8 @@
"use-prefers-color-scheme": "^1.1.3"
},
"peerDependencies": {
"react": ">=16.8.0",
"react-dom": ">=16.8.0"
"react": ">=16.14.0",
"react-dom": ">=16.14.0"
},
"devDependencies": {
"@latitude-data/eslint-config": "workspace:*",
Expand Down
5 changes: 3 additions & 2 deletions packages/client/react/src/MainProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { FC } from 'react'
import { LatitudeApiProvider, type QueryClientProviderProps } from './data'
import { LatitudeThemeProvider, type ThemeProviderProps } from './lib'

Expand All @@ -6,12 +7,12 @@ type LatitudeProviderProps = QueryClientProviderProps &
theme?: false | ThemeProviderProps['theme']
}

function LatitudeProvider({
const LatitudeProvider: FC<LatitudeProviderProps> = ({
children,
theme,
mode,
...props
}: LatitudeProviderProps) {
}: LatitudeProviderProps) => {
return (
<LatitudeApiProvider {...props}>
{theme !== false ? (
Expand Down
3 changes: 2 additions & 1 deletion packages/client/react/src/data/useQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export function useQuery({
() => [createQueryKey(queryPath, params)],
[queryPath, params],
)
const query = useReactQuery({
const query = useReactQuery<QueryResultPayload>({
...tanstaskQueryOptions,
queryKey: queryKeyProp,
queryFn: async () => api.getQuery({ queryPath, params }),
Expand Down Expand Up @@ -68,6 +68,7 @@ export function useQuery({

return {
...query,
error: query.error as Error,
compute,
download,
isDownloading,
Expand Down
6 changes: 3 additions & 3 deletions packages/client/react/src/lib/ui/column/index.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import * as React from 'react'
import { theme } from '@latitude-data/client'
interface Props extends React.HTMLAttributes<HTMLDivElement> {}
import { HTMLAttributes, forwardRef } from 'react'
interface Props extends HTMLAttributes<HTMLDivElement> {}

const Column = React.forwardRef<HTMLDivElement, Props>(
const Column = forwardRef<HTMLDivElement, Props>(
({ className, ...props }, ref) => (
<div
ref={ref}
Expand Down
Loading

0 comments on commit 0ce4ca7

Please sign in to comment.