-
-
Save marco-souza/264420002da3afd25730533f313a951b to your computer and use it in GitHub Desktop.
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
state = [ | |
action1, | |
action1, | |
] | |
// hook | |
const useFilterPedingAction = key => state.filter(item => ( | |
item.status === 'pending' && | |
item.name === key | |
)) | |
// usage | |
const { listActions, getFilteredActions } = useActions() | |
const listSSHActions = getFilteredActions(listActions, 'ssh') |
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
const { fetchSSHKeys } = useActions() | |
const { listActions, getFilteredActions } = useActions() | |
const [previousValues, setPreviousValues] = useState({ | |
ssh: 0, | |
}) | |
useEffect(() => { | |
const sshCount = getFilteredActions(listActions, 'keys') | |
if (sshCount !== previousState.ssh) { | |
setPreviousValues({ | |
ssh: sshCount, | |
...previousValues | |
}) | |
fetchSSHKeys() | |
} | |
}, [listActions]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment