Skip to content

Instantly share code, notes, and snippets.

@CITGuru
Created July 26, 2019 09:53
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 CITGuru/77d43cb5e546d2cda8ecc646b8b4af98 to your computer and use it in GitHub Desktop.
Save CITGuru/77d43cb5e546d2cda8ecc646b8b4af98 to your computer and use it in GitHub Desktop.
export const useModalWithData = (
initialMode = false,
initialSelected = null
) => {
const [modalOpen, setModalOpen] = useModal(initialMode)
const [selected, setSelected] = useState(initialSelected)
const setModalState = state => {
setModalOpen(state)
if (state === false) {
setSelected(null)
}
}
return { modalOpen, setModalOpen, selected, setSelected, setModalState }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment