Skip to content

Commit

Permalink
feat(taro): 新增 useSubmit
Browse files Browse the repository at this point in the history
  • Loading branch information
fjc0k committed Jul 10, 2020
1 parent 3745779 commit fbe8d8a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/taro/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@
// @index(['./**/*.ts', '!./**/*.test.*'], f => `export * from '${f.path}'`)
export * from './submit'
export * from './useAutoStopPullDownRefresh'
export * from './useSubmit'
// @endindex
9 changes: 9 additions & 0 deletions src/taro/useSubmit.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import React, { useCallback } from 'react'
import { submit, SubmitActionPayload } from './submit'

export function useSubmit<TResult>(
action: (payload: SubmitActionPayload) => Promise<TResult>,
deps: React.DependencyList,
): () => Promise<TResult> {
return useCallback(() => submit(action), deps)
}

0 comments on commit fbe8d8a

Please sign in to comment.