useActionCallback.js
2 years ago
useActionDetail.js
2 years ago
useActions.js
2 years ago
useActionsEdit.js
2 years ago
useCurrentAction.js
2 years ago
useRequestFields.js
2 years ago
useSanitizeFieldsMap.js
2 years ago
useUpdateCurrentAction.js
2 years ago
useUpdateCurrentActionMeta.js
2 years ago
withCurrentAction.js
2 years ago
withDispatchActionLoading.js
2 years ago
withRequestFields.js
2 years ago
withSelectActionLoading.js
2 years ago
useCurrentAction.js
21 lines
| 1 | const { |
| 2 | useSelect, |
| 3 | useDispatch, |
| 4 | } = wp.data; |
| 5 | |
| 6 | function useCurrentAction() { |
| 7 | const [ currentAction, currentSettings ] = useSelect( select => { |
| 8 | const state = select( 'jet-forms/actions' ).getCurrentAction(); |
| 9 | const settings = select( 'jet-forms/actions' ).getCurrentSettings(); |
| 10 | |
| 11 | return [ state, settings ]; |
| 12 | } ); |
| 13 | |
| 14 | const { |
| 15 | updateCurrentSettings: updateSettings, |
| 16 | } = useDispatch( 'jet-forms/actions' ); |
| 17 | |
| 18 | return { currentAction, currentSettings, updateSettings }; |
| 19 | } |
| 20 | |
| 21 | export default useCurrentAction; |