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 <git@crutchcorn.dev>
This commit is contained in:
Julien Delort
2023-10-30 03:46:12 -04:00
committed by GitHub
parent bde212f23b
commit a3a8d97fcc
5 changed files with 30 additions and 20 deletions

View File

@@ -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",

View File

@@ -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

View File

@@ -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

View File

@@ -0,0 +1,5 @@
import { useEffect, useLayoutEffect } from 'react'
export const useIsomorphicLayoutEffect =
// @ts-ignore
typeof window !== 'undefined' ? useLayoutEffect : useEffect