React Aspectral
HOC that causes any component to dynamically resize to maintain a given aspect ratio.
Based upon react-resize-detector.
Installation
npm install react-aspectral --save
Example usage
;; const MyComp = { return <div style=width: '100%' height: '100%' background: 'red'> <p>This is my component</p> </div> ;}; // 16:9 ratioconst Widescreen = MyComp; ReactDom;
API
Provide Aspectral with the relative width and relative height as parameters:
This returns a function that you can pass your component into:
MyComp
All props given to MyComp
are passed through to it's children.