mirror of
https://github.com/LukeHagar/form.git
synced 2025-12-10 04:19:54 +00:00
feat: remove getInputProps to support React Native
This commit is contained in:
committed by
Corbin Crutchley
parent
2a31bd8219
commit
7980336d03
@@ -1,5 +1,4 @@
|
||||
export type {
|
||||
ChangeProps,
|
||||
DeepKeys,
|
||||
DeepValue,
|
||||
FieldApiOptions,
|
||||
@@ -9,12 +8,9 @@ export type {
|
||||
FieldState,
|
||||
FormOptions,
|
||||
FormState,
|
||||
InputProps,
|
||||
RequiredByKey,
|
||||
Updater,
|
||||
UpdaterFn,
|
||||
UserChangeProps,
|
||||
UserInputProps,
|
||||
ValidationCause,
|
||||
ValidationError,
|
||||
ValidationMeta,
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
/// <reference lib="dom" />
|
||||
import { render } from '@testing-library/react'
|
||||
import '@testing-library/jest-dom'
|
||||
import * as React from 'react'
|
||||
@@ -25,7 +26,7 @@ describe('createFormFactory', () => {
|
||||
<form.Field
|
||||
name="firstName"
|
||||
children={(field) => {
|
||||
return <p>{field.getInputProps().value}</p>
|
||||
return <p>{field.state.value}</p>
|
||||
}}
|
||||
/>
|
||||
</form.Provider>
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
/// <reference lib="dom" />
|
||||
import * as React from 'react'
|
||||
import { render, waitFor } from '@testing-library/react'
|
||||
import userEvent from '@testing-library/user-event'
|
||||
@@ -26,7 +27,12 @@ describe('useField', () => {
|
||||
defaultValue="FirstName"
|
||||
children={(field) => {
|
||||
return (
|
||||
<input data-testid="fieldinput" {...field.getInputProps()} />
|
||||
<input
|
||||
data-testid="fieldinput"
|
||||
value={field.state.value}
|
||||
onBlur={field.handleBlur}
|
||||
onChange={(e) => field.handleChange(e.target.value)}
|
||||
/>
|
||||
)
|
||||
}}
|
||||
/>
|
||||
@@ -61,7 +67,9 @@ describe('useField', () => {
|
||||
<input
|
||||
data-testid="fieldinput"
|
||||
name={field.name}
|
||||
{...field.getInputProps()}
|
||||
value={field.state.value}
|
||||
onBlur={field.handleBlur}
|
||||
onChange={(e) => field.setValue(e.target.value)}
|
||||
/>
|
||||
<p>{field.getMeta().error}</p>
|
||||
</div>
|
||||
@@ -100,7 +108,9 @@ describe('useField', () => {
|
||||
<input
|
||||
data-testid="fieldinput"
|
||||
name={field.name}
|
||||
{...field.getInputProps()}
|
||||
value={field.state.value}
|
||||
onBlur={field.handleBlur}
|
||||
onChange={(e) => field.handleChange(e.target.value)}
|
||||
/>
|
||||
<p>{field.getMeta().error}</p>
|
||||
</div>
|
||||
@@ -143,7 +153,9 @@ describe('useField', () => {
|
||||
<input
|
||||
data-testid="fieldinput"
|
||||
name={field.name}
|
||||
{...field.getInputProps()}
|
||||
value={field.state.value}
|
||||
onBlur={field.handleBlur}
|
||||
onChange={(e) => field.handleChange(e.target.value)}
|
||||
/>
|
||||
<p>{field.getMeta().error}</p>
|
||||
</div>
|
||||
@@ -189,7 +201,9 @@ describe('useField', () => {
|
||||
<input
|
||||
data-testid="fieldinput"
|
||||
name={field.name}
|
||||
{...field.getInputProps()}
|
||||
value={field.state.value}
|
||||
onBlur={field.handleBlur}
|
||||
onChange={(e) => field.handleChange(e.target.value)}
|
||||
/>
|
||||
<p>{field.getMeta().error}</p>
|
||||
</div>
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
/// <reference lib="dom" />
|
||||
import { render } from '@testing-library/react'
|
||||
import userEvent from '@testing-library/user-event'
|
||||
import '@testing-library/jest-dom'
|
||||
@@ -25,7 +26,12 @@ describe('useForm', () => {
|
||||
defaultValue={''}
|
||||
children={(field) => {
|
||||
return (
|
||||
<input data-testid="fieldinput" {...field.getInputProps()} />
|
||||
<input
|
||||
data-testid="fieldinput"
|
||||
value={field.state.value}
|
||||
onBlur={field.handleBlur}
|
||||
onChange={(e) => field.handleChange(e.target.value)}
|
||||
/>
|
||||
)
|
||||
}}
|
||||
/>
|
||||
@@ -61,7 +67,7 @@ describe('useForm', () => {
|
||||
<form.Field
|
||||
name="firstName"
|
||||
children={(field) => {
|
||||
return <p>{field.getInputProps().value}</p>
|
||||
return <p>{field.state.value}</p>
|
||||
}}
|
||||
/>
|
||||
</form.Provider>
|
||||
|
||||
Reference in New Issue
Block a user