AdrianMachado / KaiUI

React component library for KaiOS apps
MIT License
187 stars 39 forks source link

Allow single child element in list view and narrowing typing #40

Closed ZuevArseniy closed 3 years ago

ZuevArseniy commented 3 years ago

After TS was introduced, children components for views component (ListView, and others) were set to any[], which from one hand not allows to use it with single child, which is very much valid use case (see ss):

before_fix

On the other hand it doesn't support 'any' children, but rather children, that have props (I guess it should be ReactElement).

I tested fix with example app: after_fix still_works

I'm new to both React and TS, so please let me know if the fix I provided is not optimal or is not according to common React/TS practices