Material UI Portal + TypeScript - типы свойства 'children' несовместимы - PullRequest
0 голосов
/ 03 июня 2019

Визуализация компонента с порталом Material-UI, содержащим некоторые кнопки UI материала.

<Portal container={this.myContainer}>
    <Button onClick={this.handleClick}>Do something</Button>
    //some other buttons
</Portal>

Это приводит к ошибке машинописи

TypeScript error: Type '{ children: Element[]; container: any; }' is not assignable to type 'Readonly<PortalProps>'.
  Types of property 'children' are incompatible.
Type 'Element[]' is not assignable to type 'ReactElement<any, string | ((props: any) => ReactElement<any, string | ... | (new (props: any) => Component<any, any, any>)> | null) | (new (props: any) => Component<any, any, any>)>'.

Материал пользовательского интерфейса v.3.9.0.Не удалось найти библиотеку типов, которая решает эту конкретную проблему

1 Ответ

0 голосов
/ 06 июня 2019

Эту ошибку можно устранить, обернув содержимое портала одним div:

<Portal container={this.myContainer}>
    <div>
        <Button onClick={this.handleClick}>
            Do something
        </Button>
         //some other buttons
    </div>
</Portal>
...