![](/img/trans.png)
[英]Passing down onClick Functions: [ESLINT] JSX props should not use .bind() (react/jsx-no-bind)
[英]Formik throwing Error: JSX props should not use functions in React
這個test.tsx :
<Form>
<Field name='name' validate={validateFunc}>
{({ field, form }) => (
<FormControl isInvalid={form.errors.name && form.touched.name}>
<FormLabel htmlFor='name'>Default</FormLabel>
<Input {...field} id='name' placeholder='name' />
<FormErrorMessage>{form.errors.name}</FormErrorMessage>
</FormControl>
)}
</Field>
產量
Error: JSX props should not use functions react/jsx-no-bin
我知道為什么這很糟糕,但我不知道如何改變它。
<Field name='name' validate={() => validateFunc}>
{({ field, form }) => (
<FormControl isInvalid={form.errors.name && form.touched.name}>
<FormLabel htmlFor='name'>Default</FormLabel>
<Input {...field} id='name' placeholder='name' />
<FormErrorMessage>{form.errors.name}</FormErrorMessage>
</FormControl>
)}
</Field>
也許你可以試試這個來解決你的問題
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.