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

React spread operation of JSX elements inside map

$
0
0

I am mapping over a array inside a array for a Picker and am struggeling to figure out how to return the JSX elements rather than the JSX element array.

code example:

{modelA.map((mA) => {
    const pickerItems = mA.modelB.map((mA) =>
        <Picker.Item value={mA} ... />,
    );
    return pickerItems;
})}

usually my aproach would be to make use of spread operators. but they do not do well in this syntax.

this:

{...modelA.map((mA) => {
    const pickerItems = mA.modelB.map((mA) =>
        <Picker.Item value={mA} ... />,
    );
    return pickerItems;
})}

is illegal: Spread children are not supported in React.

My dirty take on this would be to configure it pre render. but i'd rather not.

any suggestions?


Viewing all articles
Browse latest Browse all 6211

Trending Articles



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