-
-
Notifications
You must be signed in to change notification settings - Fork 31.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[material-ui][FormControl] Typescript error: Cannot access e.target.checked
#41843
Comments
e.target.checked
for FormControlLabel
e.target.checked
You can utilize the Actually, I see that it should be removed in v6 and |
Thanks for the callout @ZeeshanTamboli. I created an issue to track this: #41925 |
Steps to reproduce
Link to live example: https://stackblitz.com/edit/react-lt4tqf?file=Demo.tsx%3AL184
Current behavior
No response
Expected behavior
No response
Context
Im trying to figure out how to type
FormControlLabel.onChange
so we can accesse.target.checked
?using
React.SyntheticEvent<HTMLInputElement>
doesnt let us access.checked
and when I change it to
React.ChangeEvent<HTMLInputElement>
it works but then I get a different type error when passing the function toFormControlLabel.onChange
I could pass this to
Switch.onChange
but in my actual code, Im passingname="<some-name>"
to theFormControlLabel
which lets me accesse.target.name
in the event handler so I can reuse state logic.Your environment
npx @mui/envinfo
These might not be the latest but using latest in stackblitz
https://stackblitz.com/edit/react-lt4tqf?file=Demo.tsx,node_modules%2F%40mui%2Fmaterial%2FFormControlLabel%2FFormControlLabel.d.ts
Search keywords: e.target.checked
The text was updated successfully, but these errors were encountered: