Skip to content

Commit

Permalink
reverse hooks before reduce
Browse files Browse the repository at this point in the history
  • Loading branch information
dimapaloskin committed Nov 10, 2018
1 parent 60eaa70 commit 6d0b844
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules
dist
.vscode
4 changes: 3 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ export const useSharedHooksState = (selector: Function) => {
export const withSharedHooks = (hooks: { [key: any]: SharedHook }) => (
Component: React.ComponentType<*>,
) => {
const hooksArray: Array<SharedHook> = Object.keys(hooks).map(key => hooks[key])
const hooksArray: Array<SharedHook> = Object.keys(hooks)
.map(key => hooks[key])
.reverse()

const GlobalSharedHooksProvider = (props: *) => {
const nestedProviders = hooksArray.reduce((acc, { Provider }) => {
Expand Down

0 comments on commit 6d0b844

Please sign in to comment.