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?: any

Ignored by React.

Only kept in types for backwards compatibility. Will be removed in a future major release.

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'