Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

React 18 and 19 #1467

Merged
merged 2 commits into from
Dec 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@
"@kubb/react": "workspace:*",
"@mermaid-js/mermaid-cli": "^11.4.2",
"@types/node": "^20.17.10",
"@types/react": "^18.3.16",
"@types/react": "catalog:",
"cross-env": "^7.0.3",
"react": "^18.3.1",
"react": "catalog:",
"unplugin-kubb": "workspace:^",
"vite": "^5.4.11"
"vite": "^6.0.3"
},
"packageManager": "pnpm@9.12.0",
"packageManager": "pnpm@9.15.0",
"engines": {
"node": ">=20",
"pnpm": ">=8.15.0"
Expand Down
2 changes: 1 addition & 1 deletion e2e/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"@tanstack/vue-query": "^5.62.7",
"axios": "^1.7.9",
"msw": "^2.6.8",
"react": "^18.3.1",
"react": "catalog:",
"solid-js": "^1.9.3",
"svelte": "^3.59.2",
"swr": "^2.2.5",
Expand Down
4 changes: 2 additions & 2 deletions examples/react-query/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@
"@tanstack/react-query": "^5.62.7",
"@tanstack/react-query-devtools": "^5.62.7",
"axios": "^1.7.9",
"react": "^19.0.0",
"react": "^18.3.1",
"react-dom": "^19.0.0",
"unplugin-kubb": "workspace:*"
},
"devDependencies": {
"@types/react": "^19.0.1",
"@types/react": "^18.3.16",
"@types/react-dom": "^19.0.2",
"@vitejs/plugin-react": "^4.3.4",
"msw": "^1.3.5",
Expand Down
4 changes: 2 additions & 2 deletions examples/react-query/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type { FindPetsByStatusQueryParamsStatusEnum } from './gen/models'

const queryClient = new QueryClient()

function Pets(): JSX.Element {
function Pets() {
const [status, setStatus] = useState<FindPetsByStatusQueryParamsStatusEnum>('available')
const { data: pets, queryKey } = useFindPetsByStatusHook({ status }, { query: { enabled: true } })
const { data } = useUpdatePetWithFormHook(2)
Expand Down Expand Up @@ -105,7 +105,7 @@ function Pets(): JSX.Element {
)
}

export function App(): JSX.Element {
export function App() {
return (
<QueryClientProvider client={queryClient}>
<Pets />
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
"vite-tsconfig-paths": "5.1.0",
"vitest": "^2.1.8"
},
"packageManager": "pnpm@9.12.0",
"packageManager": "pnpm@9.15.0",
"engines": {
"node": ">=20",
"pnpm": ">=8.15.0"
Expand Down
6 changes: 3 additions & 3 deletions packages/plugin-client/src/clients/fetch.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Subset of AxiosRequestConfig
* Subset of FetchRequestConfig
*/
export type RequestConfig<TData = unknown> = {
baseURL?: string
Expand All @@ -12,7 +12,7 @@
headers?: [string, string][] | Record<string, string>
}
/**
* Subset of AxiosResponse
* Subset of FetchResponse
*/
export type ResponseConfig<TData = unknown> = {
data: TData
Expand All @@ -22,7 +22,7 @@
}

export const fetchClient = async <TData, TError = unknown, TVariables = unknown>(config: RequestConfig<TVariables>): Promise<ResponseConfig<TData>> => {
const response = await fetch('https://example.org/post', {
const response = await fetch(`${config.baseURL}${config.url}`, {

Check warning on line 25 in packages/plugin-client/src/clients/fetch.ts

View check run for this annotation

Codecov / codecov/patch

packages/plugin-client/src/clients/fetch.ts#L25

Added line #L25 was not covered by tests
method: config.method.toUpperCase(),
body: JSON.stringify(config.data),
signal: config.signal,
Expand Down
3 changes: 1 addition & 2 deletions packages/plugin-client/src/components/Client.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { type Operation, isOptional } from '@kubb/oas'
import type { OperationSchemas } from '@kubb/plugin-oas'
import { getComments, getPathParams } from '@kubb/plugin-oas/utils'
import { File, Function, FunctionParams } from '@kubb/react'
import type { KubbNode } from '@kubb/react/types'
import type { PluginClient } from '../types.ts'

type Props = {
Expand Down Expand Up @@ -113,7 +112,7 @@ export function Client({
paramsCasing,
pathParamsType,
operation,
}: Props): KubbNode {
}: Props) {
const path = new URLPath(operation.path, { casing: paramsCasing })
const contentType = operation.getContentType()
const isFormData = contentType === 'multipart/form-data'
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-faker/src/components/Faker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type Props = {
canOverride: boolean
}

export function Faker({ tree, description, name, typeName, seed, regexGenerator, canOverride, mapper, dateParser }: Props): KubbNode {
export function Faker({ tree, description, name, typeName, seed, regexGenerator, canOverride, mapper, dateParser }: Props) {
const fakerText = parserFaker.joinItems(
tree
.map((schema, _index, siblings) =>
Expand Down
4 changes: 2 additions & 2 deletions packages/plugin-msw/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@
"devDependencies": {
"@kubb/config-ts": "workspace:*",
"@kubb/config-tsup": "workspace:*",
"@types/react": "^18.3.16",
"react": "^18.3.1",
"@types/react": "catalog:",
"react": "catalog:",
"tsup": "catalog:",
"typescript": "catalog:"
},
Expand Down
4 changes: 2 additions & 2 deletions packages/plugin-oas/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@
"devDependencies": {
"@kubb/config-ts": "workspace:*",
"@kubb/config-tsup": "workspace:*",
"@types/react": "^18.3.16",
"react": "^18.3.1",
"@types/react": "catalog:",
"react": "catalog:",
"tsup": "catalog:",
"typescript": "catalog:"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-oas/src/components/Oas.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ type OasContextProps = {

const OasContext = createContext<OasContextProps>({})

export function Oas({ oas, children, operations, generator }: Props): KubbNode {
export function Oas({ oas, children, operations, generator }: Props) {
return <OasContext.Provider value={{ oas, generator, operations }}>{children}</OasContext.Provider>
}

Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-oas/src/components/Operation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type OperationContextProps = {

const OperationContext = createContext<OperationContextProps>({})

export function Operation({ operation, children }: Props): KubbNode {
export function Operation({ operation, children }: Props) {
return <OperationContext.Provider value={{ operation }}>{children}</OperationContext.Provider>
}

Expand Down
5 changes: 3 additions & 2 deletions packages/plugin-oas/src/components/Schema.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { createContext } from '@kubb/react'

import type { SchemaObject } from '@kubb/oas'
import type { KubbNode } from '@kubb/react/types'
import type { Key, KubbNode } from '@kubb/react/types'
import type { Schema as SchemaType } from '../SchemaMapper.ts'

export type SchemaContextProps = {
Expand All @@ -11,6 +11,7 @@ export type SchemaContextProps = {
}

type Props = {
key?: Key
name: string
value?: SchemaObject
tree?: Array<SchemaType>
Expand All @@ -22,7 +23,7 @@ const SchemaContext = createContext<SchemaContextProps>({
tree: [],
})

export function Schema({ name, value, tree = [], children }: Props): KubbNode {
export function Schema({ name, value, tree = [], children }: Props) {
return <SchemaContext.Provider value={{ name, schema: value, tree }}>{children}</SchemaContext.Provider>
}

Expand Down
4 changes: 2 additions & 2 deletions packages/plugin-react-query/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@
"devDependencies": {
"@kubb/config-ts": "workspace:*",
"@kubb/config-tsup": "workspace:*",
"@types/react": "^18.3.16",
"react": "^18.3.1",
"@types/react": "catalog:",
"react": "catalog:",
"tsup": "catalog:",
"typescript": "catalog:"
},
Expand Down
8 changes: 4 additions & 4 deletions packages/plugin-redoc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,16 @@
"@kubb/plugin-oas": "workspace:*",
"handlebars": "^4.7.8",
"mobx": "^6.13.5",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react": "catalog:",
"react-dom": "catalog:",
"redoc": "^2.2.0",
"styled-components": "^6.1.13"
},
"devDependencies": {
"@kubb/config-ts": "workspace:*",
"@kubb/config-tsup": "workspace:*",
"@types/react": "^18.3.16",
"@types/react-dom": "^18.3.5",
"@types/react": "catalog:",
"@types/react-dom": "catalog:",
"tsup": "catalog:",
"typescript": "catalog:"
},
Expand Down
7 changes: 5 additions & 2 deletions packages/plugin-redoc/src/redoc.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
import path from 'node:path'
import type { OasTypes } from '@kubb/oas'
import pkg from 'handlebars'
import React from 'react'
import { renderToString } from 'react-dom/server'
import { ServerStyleSheet } from 'styled-components'
import redoc from 'redoc'
import { ServerStyleSheet } from 'styled-components'

type BuildDocsOptions = {
title?: string
Expand Down Expand Up @@ -40,7 +41,9 @@
error(...args)
}

const html = renderToString(sheet.collectStyles(<Redoc store={store} />))
const App = Redoc as any

Check warning on line 44 in packages/plugin-redoc/src/redoc.tsx

View check run for this annotation

Codecov / codecov/patch

packages/plugin-redoc/src/redoc.tsx#L44

Added line #L44 was not covered by tests

const html = renderToString(sheet.collectStyles(<App {...{ store }} />))

Check warning on line 46 in packages/plugin-redoc/src/redoc.tsx

View check run for this annotation

Codecov / codecov/patch

packages/plugin-redoc/src/redoc.tsx#L46

Added line #L46 was not covered by tests
const state = await store.toJS()
const css = sheet.getStyleTags()

Expand Down
4 changes: 2 additions & 2 deletions packages/plugin-solid-query/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@
"devDependencies": {
"@kubb/config-ts": "workspace:*",
"@kubb/config-tsup": "workspace:*",
"@types/react": "^18.3.16",
"react": "^18.3.1",
"@types/react": "catalog:",
"react": "catalog:",
"tsup": "catalog:",
"typescript": "catalog:"
},
Expand Down
4 changes: 2 additions & 2 deletions packages/plugin-svelte-query/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@
"devDependencies": {
"@kubb/config-ts": "workspace:*",
"@kubb/config-tsup": "workspace:*",
"@types/react": "^18.3.16",
"react": "^18.3.1",
"@types/react": "catalog:",
"react": "catalog:",
"tsup": "catalog:",
"typescript": "catalog:"
},
Expand Down
4 changes: 2 additions & 2 deletions packages/plugin-swr/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@
"devDependencies": {
"@kubb/config-ts": "workspace:*",
"@kubb/config-tsup": "workspace:*",
"@types/react": "^18.3.16",
"react": "^18.3.1",
"@types/react": "catalog:",
"react": "catalog:",
"tsup": "catalog:",
"typescript": "catalog:"
},
Expand Down
4 changes: 2 additions & 2 deletions packages/plugin-ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@
"devDependencies": {
"@kubb/config-ts": "workspace:*",
"@kubb/config-tsup": "workspace:*",
"@types/react": "^18.3.16",
"react": "^18.3.1",
"@types/react": "catalog:",
"react": "catalog:",
"tsup": "catalog:",
"typescript": "catalog:"
},
Expand Down
4 changes: 2 additions & 2 deletions packages/plugin-ts/src/components/OasType.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { File, Type } from '@kubb/react'

import type { OasTypes } from '@kubb/oas'
import type { ReactNode } from 'react'
import type { KubbNode } from '@kubb/react/types'

type Props = {
/**
Expand All @@ -12,7 +12,7 @@ type Props = {
api: OasTypes.OASDocument
}

export function OasType({ name, typeName, api }: Props): ReactNode {
export function OasType({ name, typeName, api }: Props) {
return (
<>
<File.Source name={name} isExportable isIndexable>
Expand Down
3 changes: 2 additions & 1 deletion packages/plugin-ts/src/components/Type.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ export function Type({ name, typedName, tree, keysToOmit, optionalType, syntaxTy
return (
<Fragment>
{enums.map(({ name, nameNode, typeName, typeNode }, index) => (
<Fragment key={[name, nameNode].join('-')}>
// biome-ignore lint/correctness/useJsxKeyInIterable: <explanation>
<Fragment>
{nameNode && (
<File.Source name={name} isExportable isIndexable>
{print([nameNode])}
Expand Down
4 changes: 2 additions & 2 deletions packages/plugin-vue-query/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@
"devDependencies": {
"@kubb/config-ts": "workspace:*",
"@kubb/config-tsup": "workspace:*",
"@types/react": "^18.3.16",
"react": "^18.3.1",
"@types/react": "catalog:",
"react": "catalog:",
"tsup": "catalog:",
"typescript": "catalog:"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-zod/src/components/Operations.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ type Props = {
operations: Array<{ operation: Operation; data: SchemaNames }>
}

export function Operations({ name, operations }: Props): KubbNode {
export function Operations({ name, operations }: Props) {
const operationsJSON = operations.reduce(
(prev, acc) => {
prev[`"${acc.operation.getOperationId()}"`] = acc.data
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-zod/src/components/Zod.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type Props = {
keysToOmit?: string[]
}

export function Zod({ name, typeName, tree, inferTypeName, mapper, coercion, keysToOmit, description }: Props): KubbNode {
export function Zod({ name, typeName, tree, inferTypeName, mapper, coercion, keysToOmit, description }: Props) {
const hasTuple = tree.some((item) => isKeyword(item, schemaKeywords.tuple))

const output = parserZod
Expand Down
8 changes: 4 additions & 4 deletions packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,17 +87,17 @@
"@kubb/parser-ts": "workspace:*",
"execa": "^9.5.2",
"natural-orderby": "^4.0.0",
"react": "^18.3.1",
"react": "catalog:react18",
"react-devtools-core": "^5.3.2",
"react-reconciler": "^0.29.2",
"react-reconciler": "catalog:react18",
"signal-exit": "^4.1.0",
"ws": "^8.18.0"
},
"devDependencies": {
"@kubb/config-ts": "workspace:*",
"@kubb/config-tsup": "workspace:*",
"@types/react": "^18.3.16",
"@types/react-reconciler": "^0.28.9",
"@types/react": "catalog:react18",
"@types/react-reconciler": "catalog:react18",
"@types/signal-exit": "^3.0.4",
"@types/ws": "^8.5.13",
"tsup": "catalog:",
Expand Down
3 changes: 3 additions & 0 deletions packages/react/src/ReactTemplate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ export class ReactTemplate<TMeta extends Record<string, unknown> = Record<string
if (data.match(/React will try to recreat/gi)) {
return
}
if (data.match(/Each child in a list should have a unique/gi)) {
return
}
if (data.match(/The above error occurred in the <KubbErrorBoundary/gi)) {
return
}
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/components/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ type Props = {
readonly children?: KubbNode
}

export function App({ plugin, pluginManager, mode, children }: Props): KubbNode {
export function App({ plugin, pluginManager, mode, children }: Props) {
const { exit } = useContext(RootContext)

return <AppContext.Provider value={{ exit, plugin, pluginManager, mode }}>{children}</AppContext.Provider>
Expand Down
Loading
Loading