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
Bug: Property 'inputType' does not exist on type 'Event' #28517
Comments
can i work on this if it has not been assigned to anyone? |
why not? |
@dehoward @yezhonghu0503 I dont see the the object you are passing in the onclick function but im guessing the inputType key is present. looks like you are trying to get the key-value pair but its not directly available. i would write a condition to check if the inputType property exists before accessing it. Here's how you can modify this code. import React from 'react';
export default function App() {
const handleChange = (event) => {
if (event.nativeEvent && event.nativeEvent.inputType) {
console.log(JSON.stringify(event.nativeEvent.inputType));
} else {
console.log('inputType property not available');
}
};
return (
<div className='App'>
<input onChange={handleChange} />
</div>
);
} let me know if this fixes the bug. |
I guess we have to ensure that the event object is of the correct type (InputEvent) before accessing the inputType property. |
do you guys still have an error? |
React version: 18.0.0
Steps To Reproduce
create an
onChange
handler for aninput
and try to accessevent.nativeEvent.inputType
Link to code example:
https://playcode.io/1790904
The current behavior
Doesn't allow type
The expected behavior
Should allow property access
The text was updated successfully, but these errors were encountered: