Skip to content

Commit

Permalink
fix: NextJS should not throw an error anymore (#485)
Browse files Browse the repository at this point in the history
* fix: remove use-isomorphic-layout-effect package for nextjs compatibility

* chore: remove DOM from tsconfig

* chore: fix formatting errors

---------

Co-authored-by: Corbin Crutchley <git@crutchcorn.dev>
  • Loading branch information
juliendelort and crutchcorn authored Oct 30, 2023
1 parent bde212f commit a3a8d97
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 20 deletions.
3 changes: 1 addition & 2 deletions packages/react-form/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@
"dependencies": {
"@tanstack/form-core": "workspace:*",
"@tanstack/react-store": "0.1.3",
"@tanstack/store": "0.1.3",
"use-isomorphic-layout-effect": "^1.1.2"
"@tanstack/store": "0.1.3"
},
"peerDependencies": {
"react": "^17.0.0 || ^18.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/react-form/src/useField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { useStore } from '@tanstack/react-store'
import type { DeepKeys, DeepValue, Narrow } from '@tanstack/form-core'
import { FieldApi, functionalUpdate } from '@tanstack/form-core'
import { useFormContext, formContext } from './formContext'
import useIsomorphicLayoutEffect from 'use-isomorphic-layout-effect'
import type { UseFieldOptions } from './types'
import { useIsomorphicLayoutEffect } from './useIsomorphicLayoutEffect'

declare module '@tanstack/form-core' {
// eslint-disable-next-line no-shadow
Expand Down
2 changes: 1 addition & 1 deletion packages/react-form/src/useForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { useStore } from '@tanstack/react-store'
import React, { type ReactNode, useState } from 'react'
import { type UseField, type FieldComponent, Field, useField } from './useField'
import { formContext } from './formContext'
import useIsomorphicLayoutEffect from 'use-isomorphic-layout-effect'
import { useIsomorphicLayoutEffect } from './useIsomorphicLayoutEffect'

declare module '@tanstack/form-core' {
// eslint-disable-next-line no-shadow
Expand Down
5 changes: 5 additions & 0 deletions packages/react-form/src/useIsomorphicLayoutEffect.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { useEffect, useLayoutEffect } from 'react'

export const useIsomorphicLayoutEffect =
// @ts-ignore
typeof window !== 'undefined' ? useLayoutEffect : useEffect
38 changes: 22 additions & 16 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a3a8d97

Please sign in to comment.