-
Notifications
You must be signed in to change notification settings - Fork 190
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: clean SwapProps and standardize event handler logic (#177)
* refactor: standardize conditional handler logic * fix: swap props
- Loading branch information
Showing
5 changed files
with
30 additions
and
16 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { useCallback } from 'react' | ||
|
||
export function useConditionalHandler<T extends (...args: any[]) => void | boolean | Promise<boolean>>( | ||
handler?: T | ||
): (...params: Parameters<T>) => Promise<boolean> { | ||
return useCallback( | ||
async (...params) => { | ||
if (!handler) return true | ||
|
||
try { | ||
const result = await handler(...params) | ||
if (result === false) return false | ||
} catch { | ||
return false | ||
} | ||
return true | ||
}, | ||
[handler] | ||
) | ||
} |
0d74a8c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
widgets – ./
widgets-git-main-uniswap.vercel.app
widgets-seven-tau.vercel.app
widgets-uniswap.vercel.app