Skip to content

Instantly share code, notes, and snippets.

@zilahir
Last active April 2, 2020 10:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zilahir/b2bdd70f5e1c6038b4e45b24fe2d39cc to your computer and use it in GitHub Desktop.
Save zilahir/b2bdd70f5e1c6038b4e45b24fe2d39cc to your computer and use it in GitHub Desktop.
hook
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