I'm trying to make custom view
component base on device size, but typescript complain about number, it said Object is possibly 'undefined'
, here is the code
export interface ViewContainerProps { style?: ViewStyle | ViewStyle[]; children?: React.ReactNode; percentWidth?: number; percentHeight?: number;}export const ViewContainer = (props: ViewContainerProps) => { const {style, children, percentHeight,percentWidth} = props; return (<View style={[style, {height: onePercentHeight * percentHeight}]}> // no, this number is undefined!? {children}</View> );};
What happen, how to fix this, thank you guys a lots