1import React, { PropsWithChildren, useEffect } from 'react'; 2 3import { Collapsible } from '~/ui/components/Collapsible'; 4 5type Props = PropsWithChildren<object> & { title?: string; abstract?: boolean }; 6 7export const ConfigReactNative = ({ children, abstract, title }: Props) => { 8 if (!abstract) { 9 title ??= 'Are you using this library in a bare React Native app?'; 10 } else { 11 title ??= 'Working in a bare React Native app?'; 12 } 13 14 useEffect(() => { 15 if (typeof children === 'string') { 16 throw new Error( 17 `Content inside 'ConfigReactNative' needs to be surrounded by new lines to be parsed as markdown.\n\nMake sure there is a blank new line before and after this content: '${children}'` 18 ); 19 } 20 }, [children]); 21 22 return <Collapsible summary={title}>{children}</Collapsible>; 23}; 24