Skip to content

Commit

Permalink
Moved to useLayoutEffect for subscription (#50)
Browse files Browse the repository at this point in the history
Copied from #47 but for Preact
module
  • Loading branch information
Ty3uK authored and ai committed May 10, 2019
1 parent 2cc8382 commit 64360cb
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion preact/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@ var hooks = require('preact/hooks')

var StoreContext = require('./context')

var useIsomorphicLayoutEffect =
typeof window !== 'undefined' ? hooks.useLayoutEffect : hooks.useEffect

module.exports = function () {
var keys = [].slice.call(arguments)

var store = hooks.useContext(StoreContext)
var rerender = hooks.useState({ })

hooks.useEffect(function () {
useIsomorphicLayoutEffect(function () {
return store.on('@changed', function (_, changed) {
var changesInKeys = keys.some(function (key) {
return key in changed
Expand Down

0 comments on commit 64360cb

Please sign in to comment.