Select trigger error when using both MenuItem(s) and mapping over array
See original GitHub issueDescribe the bug Combining MenuItem component and mapping over variable triggers tslint error when using Select component
To Reproduce Steps to reproduce the behavior:
<Select name="test">
<MenuItem value={-1}>Option #1</MenuItem>
{options.map((o) => (
<MenuItem value={o.id} key={o.id}>
{o.name}
</MenuItem>
))}
</Select>
which gives me this error
Type ‘Element[]’ is missing the following properties from type ‘ReactElement<any, string | ((props: any) => ReactElement<any, string | … | (new (props: any) => Component<any, any, any>)> | null) | (new (props: any) => Component<any, any, any>)>’: type, props, keyts(2739)
Expected behavior I expected to not get an error (i get none if i use TextField component set to select or if i use Select directly from material-ui
Additional context doing this work, but it feels wrong
<Select name="test">
{[
<MenuItem value={-1}>Option #1</MenuItem>,
...options.map((c) => (
<MenuItem value={o.id} key={o.id}>
{0.name}
</MenuItem>
)),
]}
</Select>
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (5 by maintainers)
Top Results From Across the Web
reactjs - MUI Select custom MenuItem not working properly
Expected behavior: when I click on the MenuItem , it gets selected in the Select component. Actual behavior: nothing happens. The thing is,...
Read more >Angular directives for Bootstrap - AngularUI
This repository contains a set of native AngularJS directives based on Bootstrap's markup and CSS. As a result no dependency on jQuery or...
Read more >Lists and Keys - React
In React, transforming arrays into lists of elements is nearly identical. ... Below, we loop through the numbers array using the JavaScript map()...
Read more >list - Manual - PHP
Like array(), this is not really a function, but a language construct. list() is used to assign a list of variables in one...
Read more >FactoryTalk View Machine Edition User's Guide
No patent liability is assumed by Rockwell Automation, Inc. with respect to use of information, circuits, equipment, or software described in this manual....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks and apologies for not ‘getting it’ at first. =)
Thanks, works for me as well 😃