MainScreenComponent dynamically adjusts the layout and dimensions of its child components based on window size, stacking mode, and specified width/height fractions, supporting flexible and responsive screen layouts.

This component determines the appropriate dimensions for main and secondary components based on stacking mode, screen width, and main component size, and can conditionally arrange child components in a column or row based on screen width.

import React, { useState } from 'react';
import { MainScreenComponent } from 'mediasfu-reactnative-expo';

function App() {
const [componentSizes, setComponentSizes] = useState<ComponentSizes>({
mainHeight: 0,
otherHeight: 0,
mainWidth: 0,
otherWidth: 0,
});

return (
<MainScreenComponent
mainSize={70}
doStack={true}
containerWidthFraction={1}
containerHeightFraction={1}
updateComponentSizes={setComponentSizes}
showControls={true}
componentSizes={componentSizes}
>
<MainContent />
<SecondaryContent />
</MainScreenComponent>
);
}

export default App;

Properties

propTypes?: WeakValidationMap<MainScreenComponentOptions>

Used to declare the types of the props accepted by the component. These types will be checked during rendering and in development only.

We recommend using TypeScript instead of checking prop types at runtime.

contextTypes?: ValidationMap<any>

Lets you specify which legacy context is consumed by this component.

defaultProps?: Partial<MainScreenComponentOptions>

Used to define default values for the props accepted by the component.

type Props = { name?: string }

const MyComponent: FC<Props> = (props) => {
return <div>{props.name}</div>
}

MyComponent.defaultProps = {
name: 'John Doe'
}
displayName?: string

Used in debugging messages. You might want to set it explicitly if you want to display a different name for debugging purposes.


const MyComponent: FC = () => {
return <div>Hello!</div>
}

MyComponent.displayName = 'MyAwesomeComponent'