npm i -D react-container-query-container
- initialize the container queries
prolyfill once in the top of your app. (set
postcss: true
if you're using the postcss-plugin):import { initializeContainers } from 'react-container-query-container'; initializeContainers({ postcss: true });
- decorate your component with the higher-order component, passing an optional
callback to execute when the component is reevaluated:
import ContainerQueryContainer from 'react-container-query-container'; @ContainerQueryContainer({ componentShouldReevaluate: () => console.log('reevaluated.'), }) class DemoComponent extends Component { …
Welcome to the future!
Collaborating on this React component:
You will need the following things properly installed on your computer.
git clone https://github.com/VinSpee/react-container-query-container.git
this repository- change into the new directory
npm install
nwb serve
will run the component's demo app- Visit the demo at http://localhost:3000
nwb test
will run the tests oncenwb test --server
will run the tests on every change
nwb build