typing warning with Chakra UI's `Input` on sample-app
See original GitHub issueRunning the sample-app example on this repository, which uses Chakra UI, seems to be giving a Type 'string' is not assignable to type 'never'. ts(2322)
warning on the id
property at app/components/FormInput.jsx:30
. Including the snippet here for easier reading:
// ...
return (
<>
<FormControl isInvalid={!!error} isRequired={isRequired}>
<FormLabel htmlFor={name}>{label}</FormLabel>
<Input
{...getInputProps({
id: name,
...rest,
})}
/>
{error && <FormErrorMessage>{error}</FormErrorMessage>}
</FormControl>
</>
);
Now, everything still seems to work fine and my experience with Chakra UI is none so I might be missing something obvious, but seeing as this is an official example I’m wondering if there’s anything to be done about it…
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Input - Chakra UI
Input component is a component that is used to get user input in a text field.
Read more >Get Chakra UI working with Remix Run · Issue #5166 - GitHub
I've tried adding the provider to the server.entry file and using the provided solution @primos63 added above. Neither seems to fix the issue....
Read more >How to create forms with Chakra UI in React apps
I've been using this UI library for a recent project and thought exploring it more might be a good idea. Learn how to...
Read more >How to build a Habit Tracker with Prisma, Chakra UI, and React
In this tutorial, you'll learn how to built a Habit Tracker app “Streaks” from scratch with Prisma, Chakra UI, and React. We use...
Read more >Chakra UI and React-Hook-Form –How to Build Beautiful Forms
Chakra UI and React-Hook-Form –How to Build Beautiful Forms ... <form onSubmit={handleSubmit(onSubmit)}> <input type=”text” ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@rmobis, I’m going to end up reverting that fix, I think. I’m working on adding to
getInputProps
and running into issues with the current typing. I’ve tried the old typing with other component libraries and Chakra seems to be the only one with this issue.For an alternate fix, you can get the correct functionality without
as never
oras any
is by supplying the generic directly.I found a solution and will publish it. Somehow switching from
Omit<T, 'defaultValue' | 'name'>
toT & { defaultValue?: never, name?: never }
fixed it. One downside to this is thatdefaultValue
andname
show up as autocomplete options, but it still prevents you from setting them.