Function MainContainerComponent

MainContainerComponent is a React functional component that renders a container with customizable dimensions and margins. The container's dimensions adapt to the window size based on provided width and height fractions, and it updates dynamically on window resize or orientation changes.

import React from 'react';
import { MainContainerComponent } from 'mediasfu-reactjs';

function App() {
return (
<MainContainerComponent
backgroundColor="black"
containerWidthFraction={0.5}
containerHeightFraction={0.5}
marginLeft={10}
marginRight={10}
marginTop={10}
marginBottom={10}
padding={10}
>
<ChildComponent />
</MainContainerComponent>
);
}

export default App;

Properties

propTypes?: WeakValidationMap<MainContainerComponentOptions>

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<MainContainerComponentOptions>

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'