Last active
April 2, 2020 10:18
-
-
Save zilahir/b2bdd70f5e1c6038b4e45b24fe2d39cc to your computer and use it in GitHub Desktop.
hook
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useState, useCallback } from 'react' | |
import { useStore } from 'react-redux' | |
export const useStructure = param => { | |
const store = useStore() | |
const fetchedStructure = store.getState().fetchStructure.structure | |
return { | |
structure, | |
setStructure, | |
getParentTagList: useCallback(tagId => setStructure( | |
[tagId], | |
)), | |
} | |
} | |
// usage | |
const structure = useStructure() | |
const parentTagList = structure.getParentTagList(8) | |
console.debug('parentTagList', parentTagList) // -> undefined |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment