How to handle Unknown Prop warning on aria/button for onPress
?
#3666
-
So, I am getting this warning on using react-aria/button As far as I am aware, it does not have any side-effect, but I still would like to remove this warning on every button used. Any help is appreciated. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Can you provide a CodeSandbox of the code that is causing this warning? How is it different from the examples in the docs? |
Beta Was this translation helpful? Give feedback.
-
You're probably spreading all the props down to the button element. You'll want to spread only import {useButton} from 'react-aria';
import {useRef} from 'react';
function Button(props) {
let ref = useRef();
let { buttonProps } = useButton(props, ref);
let { children } = props;
return (
<button {...buttonProps} ref={ref}>
{children}
</button>
);
} or be intentional with what get's passed down so that it's only valid DOM props. |
Beta Was this translation helpful? Give feedback.
You're probably spreading all the props down to the button element. You'll want to spread only
buttonProps
:or be intentional with what get's passed down so that it's only valid DOM props.