mirror of
https://github.com/storybookjs/storybook.git
synced 2025-03-20 05:02:37 +08:00
Merge pull request #21304 from storybookjs/valentin/fix-next-js-types-in-13.2.0
Fix Next.js type references in Next.js >= 13.2.0
This commit is contained in:
commit
31c97a2138
7
code/frameworks/nextjs/template/next-env.d.ts
vendored
Normal file
7
code/frameworks/nextjs/template/next-env.d.ts
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
// Reference necessary since Next.js 13.2.0, because types in `next/navigation` are not exported per default, but
|
||||
// type references are dynamically created during Next.js start up.
|
||||
// See https://github.com/vercel/next.js/commit/cdf1d52d9aed42d01a46539886a4bda14cb77a99
|
||||
// for more insights.
|
||||
|
||||
/// <reference types="next" />
|
||||
/// <reference types="next/navigation-types/navigation" />
|
@ -14,7 +14,7 @@ function Component() {
|
||||
const segment = useSelectedLayoutSegment();
|
||||
const segments = useSelectedLayoutSegments();
|
||||
|
||||
const searchParamsList = Array.from(searchParams.entries());
|
||||
const searchParamsList = searchParams ? Array.from(searchParams.entries()) : [];
|
||||
|
||||
const routerActions = [
|
||||
{
|
||||
|
@ -1,3 +1,4 @@
|
||||
// usePathname and useSearchParams are only usable if experimental: {appDir: true} is set in next.config.js
|
||||
import { useRouter, usePathname, useSearchParams } from 'next/navigation';
|
||||
import React from 'react';
|
||||
import type { Meta, StoryObj } from '@storybook/react';
|
||||
@ -7,7 +8,7 @@ function Component() {
|
||||
const pathname = usePathname();
|
||||
const searchParams = useSearchParams();
|
||||
|
||||
const searchParamsList = Array.from(searchParams.entries());
|
||||
const searchParamsList = searchParams ? Array.from(searchParams.entries()) : [];
|
||||
|
||||
const routerActions = [
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user