Skip to content

Commit

Permalink
chore: Remove deprecated APIs
Browse files Browse the repository at this point in the history
BREAKING CHANGE: the following deprecated APIs have been removed:
- `queryTypes` bag of parsers -> use individual `parseAsXYZ` parsers
  for better tree-shakeability.
- `subscribeToQueryUpdates` helper -> since Next.js 14.0.5,
  `useSearchParams` is reactive to shallow search params updates
  in the app router. See #425.
- Internal types and aliases
  • Loading branch information
franky47 committed Sep 24, 2024
1 parent 56aed8b commit 7b43ec9
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 470 deletions.

This file was deleted.

16 changes: 11 additions & 5 deletions packages/e2e/src/pages/pages/useQueryState/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
import { GetServerSideProps } from 'next'
import Link from 'next/link'
import { usePathname } from 'next/navigation'
import { parseAsString, queryTypes, useQueryState } from 'nuqs'
import {
parseAsBoolean,
parseAsFloat,
parseAsInteger,
parseAsString,
useQueryState
} from 'nuqs'
import { HydrationMarker } from '../../../components/hydration-marker'

export const getServerSideProps = (async ctx => {
Expand All @@ -18,12 +24,12 @@ export const getServerSideProps = (async ctx => {

const IntegrationPage = () => {
const [string, setString] = useQueryState('string')
const [int, setInt] = useQueryState('int', queryTypes.integer)
const [float, setFloat] = useQueryState('float', queryTypes.float)
const [bool, setBool] = useQueryState('bool', queryTypes.boolean)
const [int, setInt] = useQueryState('int', parseAsInteger)
const [float, setFloat] = useQueryState('float', parseAsFloat)
const [bool, setBool] = useQueryState('bool', parseAsBoolean)
const [text, setText] = useQueryState(
'text',
queryTypes.string.withDefault('Hello, world!')
parseAsString.withDefault('Hello, world!')
)
const pathname = usePathname()
return (
Expand Down
16 changes: 11 additions & 5 deletions packages/e2e/src/pages/pages/useQueryStates/index.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
import Link from 'next/link'
import { queryTypes, useQueryStates } from 'nuqs'
import {
parseAsBoolean,
parseAsFloat,
parseAsInteger,
parseAsString,
useQueryStates
} from 'nuqs'
import { HydrationMarker } from '../../../components/hydration-marker'

const IntegrationPage = () => {
const [state, setState] = useQueryStates({
string: queryTypes.string,
int: queryTypes.integer,
float: queryTypes.float,
bool: queryTypes.boolean
string: parseAsString,
int: parseAsInteger,
float: parseAsFloat,
bool: parseAsBoolean
})
return (
<>
Expand Down
70 changes: 0 additions & 70 deletions packages/nuqs/src/deprecated.ts

This file was deleted.

2 changes: 0 additions & 2 deletions packages/nuqs/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
'use client'

export type { HistoryOptions, Options } from './defs'
export * from './deprecated'
export * from './parsers'
export { createSerializer } from './serializer'
export { subscribeToQueryUpdates } from './sync'
export type { QueryUpdateNotificationArgs, QueryUpdateSource } from './sync'
export * from './useQueryState'
export * from './useQueryStates'
15 changes: 0 additions & 15 deletions packages/nuqs/src/sync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,6 @@ declare global {
}
}

/**
* @deprecated Since Next.js introduced shallow routing in 14.0.3, this
* method is no longer needed as you can use `useSearchParams`, which will
* react to changes in the URL when the `windowHistorySupport` experimental flag
* is set.
* This method will be removed in `[email protected]`, when Next.js
* decides to land the `windowHistorySupport` flag in GA.
*/
export function subscribeToQueryUpdates(
callback: (args: QueryUpdateNotificationArgs) => void
) {
emitter.on(NOTIFY_EVENT_KEY, callback)
return () => emitter.off(NOTIFY_EVENT_KEY, callback)
}

if (typeof history === 'object') {
patchHistory()
}
Expand Down
Loading

0 comments on commit 7b43ec9

Please sign in to comment.