Function MainAspectComponent

MainAspectComponent is a React functional component that dynamically adjusts its dimensions based on window size and specified fractions, while updating screen size states (wide, medium, small) based on container width.

This component provides an adaptive container that resizes according to the window’s height and width, factoring in control visibility, and offers real-time updates for screen size breakpoints.

import React, { useState } from 'react';
import { MainAspectComponent } from 'mediasfu-reactjs';

function App() {
const [isWideScreen, setIsWideScreen] = useState(false);
const [isMediumScreen, setIsMediumScreen] = useState(false);
const [isSmallScreen, setIsSmallScreen] = useState(false);

return (
<MainAspectComponent
backgroundColor="black"
showControls={true}
containerWidthFraction={0.5}
containerHeightFraction={0.5}
defaultFraction={0.9}
updateIsWideScreen={setIsWideScreen}
updateIsMediumScreen={setIsMediumScreen}
updateIsSmallScreen={setIsSmallScreen}
>
<div>Responsive Content</div>
</MainAspectComponent>
);
}

export default App;

Properties

propTypes?: WeakValidationMap<MainAspectComponentOptions>

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

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'