Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6287

Property 'setNativeProps' does not exist on type 'ForwardRefExoticComponent'

$
0
0

I have the following code:

    const menuItemRefs = useRef<{ [key: number]: typeof View }>({});    const { isMenuVisible } = useTopMenuContext();    useEffect(() => {        const onBackPress = () => {            if (isMenuVisible) {                menuItemRefs.current[0].setNativeProps({ hasTVPreferredFocus: true });                return false;            }            return true;        };        const backHandler = BackHandler.addEventListener('hardwareBackPress', onBackPress);        return () => backHandler.remove();    }, []);

The code works perfectly but TypeScript tells me:

Property 'setNativeProps' does not exist on type 'ForwardRefExoticComponent<Pick<any, string | number | symbol> & RefAttributes>'.

The ref is returned by a plain React Native View. How can I type this properly to remove the error?


Viewing all articles
Browse latest Browse all 6287

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>