Skip to content

Commit a3a8d97

Browse files
fix: NextJS should not throw an error anymore (#485)
* fix: remove use-isomorphic-layout-effect package for nextjs compatibility * chore: remove DOM from tsconfig * chore: fix formatting errors --------- Co-authored-by: Corbin Crutchley <[email protected]>
1 parent bde212f commit a3a8d97

File tree

5 files changed

+30
-20
lines changed

5 files changed

+30
-20
lines changed

packages/react-form/package.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,7 @@
6262
"dependencies": {
6363
"@tanstack/form-core": "workspace:*",
6464
"@tanstack/react-store": "0.1.3",
65-
"@tanstack/store": "0.1.3",
66-
"use-isomorphic-layout-effect": "^1.1.2"
65+
"@tanstack/store": "0.1.3"
6766
},
6867
"peerDependencies": {
6968
"react": "^17.0.0 || ^18.0.0",

packages/react-form/src/useField.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import { useStore } from '@tanstack/react-store'
33
import type { DeepKeys, DeepValue, Narrow } from '@tanstack/form-core'
44
import { FieldApi, functionalUpdate } from '@tanstack/form-core'
55
import { useFormContext, formContext } from './formContext'
6-
import useIsomorphicLayoutEffect from 'use-isomorphic-layout-effect'
76
import type { UseFieldOptions } from './types'
7+
import { useIsomorphicLayoutEffect } from './useIsomorphicLayoutEffect'
88

99
declare module '@tanstack/form-core' {
1010
// eslint-disable-next-line no-shadow

packages/react-form/src/useForm.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { useStore } from '@tanstack/react-store'
55
import React, { type ReactNode, useState } from 'react'
66
import { type UseField, type FieldComponent, Field, useField } from './useField'
77
import { formContext } from './formContext'
8-
import useIsomorphicLayoutEffect from 'use-isomorphic-layout-effect'
8+
import { useIsomorphicLayoutEffect } from './useIsomorphicLayoutEffect'
99

1010
declare module '@tanstack/form-core' {
1111
// eslint-disable-next-line no-shadow
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { useEffect, useLayoutEffect } from 'react'
2+
3+
export const useIsomorphicLayoutEffect =
4+
// @ts-ignore
5+
typeof window !== 'undefined' ? useLayoutEffect : useEffect

pnpm-lock.yaml

+22-16
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)