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

How do I type a forwardRef? [duplicate]

$
0
0

Similar to What is the syntax for Typescript arrow functions with generics? but I have a specific scenario which didn't see to work with the solutions provided there

Also more specific with examples compared to How do I type my ref correctly in a forwardRef component?

I am trying to wrap FlatList with something that I modified that would ensures that the columns are the same width and I just made a change to allow it to pass a ref in.

Originally I had

export function FlatList<ItemT=any>( props : FlatListProps<ItemT>) {...}

So when I tried to convert it failed, and I had to resort to any as follows

import {FlatList as RNFlatList} from 'react-native';...export const FlatList = forwardRef<RNFlatList<any>, FlatListProps<any>>(...}

I tried the following, but it didn't work.

export const FlatList = <ItemT=any,>forwardRef<RNFlatList<ItemT>, FlatListProps<ItemT>>(...}

Viewing all articles
Browse latest Browse all 6287

Trending Articles



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