UNPKG

react-native-confirmation-code-field

Version:

A react-native component to input confirmation code for both Android and IOS

17 lines (16 loc) 742 B
import { useMemo } from 'react'; import { useClearByFocusCellCommon } from './useClearByFocusCell.common'; export const useClearByFocusCell = (params) => { 'use memo'; const [clearCodeByCoords, getCellOnLayoutHandler] = useClearByFocusCellCommon(params); const inputProps = useMemo(() => ({ onClick: (event) => { // @ts-expect-error - getClientRects have to be defined on the target const [offset] = event.target.getClientRects(); const locationX = event.clientX - offset.left; const locationY = event.clientY - offset.top; clearCodeByCoords({ locationX, locationY }); }, }), [clearCodeByCoords]); return [inputProps, getCellOnLayoutHandler]; };