Skip to content

Commit

Permalink
fix: πŸ› use useLayoutEffect() in useCss() to inject CSS quick
Browse files Browse the repository at this point in the history
  • Loading branch information
streamich committed Mar 20, 2019
1 parent fec8dd3 commit 7328f26
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/useCss.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {useState, useEffect} from 'react';
import {useState, useLayoutEffect} from 'react';
const {create} = require('nano-css');
const {addon: addonCssom} = require('nano-css/addon/cssom');
const {addon: addonPipe} = require('nano-css/addon/pipe');
Expand Down Expand Up @@ -37,7 +37,7 @@ addonPipe(nano);
const useCss = (css: object): string => {
const [pipe] = useState<CssPipe>(nano.pipe());

useEffect(() => {
useLayoutEffect(() => {
pipe.css(flattenSelectors(css));
return () => pipe.remove();
});
Expand Down

0 comments on commit 7328f26

Please sign in to comment.