React Window Info
A utility for subscribing to window events. Useful for conditional rendering, CSS breakpoints, or any window-based triggers.
Highlights
Quick Start
Installation
$ npm i @faceless-ui/window-info
$
$ yarn add @faceless-ui/window-info
Composition
import React from 'react';
import {
WindowInfo,
WindowInfoProvider,
withWindowInfo,
useWindowInfo
} from '@faceless-ui/window-info';
const WithWindowInfo = withWindowInfo(({ windowInfo }) => <div>{windowInfo}</div>);
const UseWindowInfo = () => <div>{useWindowInfo()}</div>;
const App = () => (
<WindowInfoProvider>
<WithWindowInfo />
<UseWindowInfo />
<WindowInfo>
{(windowInfo) => <div>{windowInfo}</div>}
<WindowInfo>
</WindowInfoProvider>
);
export default App;
For working examples, see the demo app.
Demo
$ git clone git@github.com:faceless-ui/window-info.git
$ yarn
$ yarn dev
$ open http://localhost:3000
API
Contribution
Help us, or let us help you help us.
License
MIT Copyright (c) TRBL, LLC