import { assertExists } from '@ulangi/assert' ; import { observer } from 'mobx-react' ; import * as React from 'react' ; import { ContainerProps } from './Container' ; import { ServiceRegistry } from './ServiceRegistry' ; @ observer export class Provider extends React . Component { public render ( ) { const child = assertExists ( React . Children . only ( this . props . children ) , 'Provider requires one child' ) ; if ( React . isValidElement < any > ( child ) ) { const containerProps = { componentId : child . props . componentId , screenType : child . props . screenType , theme : child . props . theme , styles : child . props . styles , passedProps : child . props . passedProps , ... ServiceRegistry . services , } ; return React . cloneElement ( child , containerProps ) ; } else { throw new Error ( 'Provider must have a valid child element.' ) ; } } }