From cd285963431efc7dc18ff561ad608058ed92ee3d Mon Sep 17 00:00:00 2001 From: Vince Speelman Date: Sun, 13 Dec 2015 12:58:44 -0500 Subject: [PATCH] add instructions for usage with react Add instructions for how to use with react, implementing ContainerQueryContainer. I made the recommended changes (no longer creating multiple instances of cq, just one at the top level). I'd love for it to be here! --- docs/usage.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/docs/usage.md b/docs/usage.md index 341108b..cebc2b0 100644 --- a/docs/usage.md +++ b/docs/usage.md @@ -64,3 +64,17 @@ It’s also possible to query color properties, for this purpose the color filte /* Styles for .element if it’s containers background-color is nearly transparent */ } ``` + +## With React + +Using a higer-order component [ContainerQueryContainer](https://github.com/VinSpee/react-container-query-container), initialize the prolyfill, and apply it to each component that needs it, optionally supplying a callback that is executed upon reevaluating. + +```js +import ContainerQueryContainer, { initializeContainers } from 'react-container-query-container'; +initializeContainers({ postcss: true }); + +@ContainerQueryContainer({ + componentShouldReevaluate: () => console.log('reevaluated.'), +}) +class DemoComponent extends Component { … +```