Skip to content

Commit

Permalink
refactor: memoized grabber component
Browse files Browse the repository at this point in the history
  • Loading branch information
lodev09 committed Apr 7, 2024
1 parent 5f312d5 commit f258213
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/TrueSheetGrabber.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import React from 'react'
import React, { memo } from 'react'
import { View, type ColorValue, type ViewProps, type ViewStyle } from 'react-native'

const GRABBER_WRAPPER_HEIGHT = 24
const GRABBER_DEFAULT_HEIGHT = 4
const GRABBER_DEFAULT_WIDTH = 32
const GRABBER_DEFAULT_COLOR = '#49454F'

interface TrueSheetGrabberProps extends ViewProps {
export interface TrueSheetGrabberProps extends ViewProps {
/**
* Is grabber visible
* @default true
Expand Down Expand Up @@ -36,7 +36,7 @@ interface TrueSheetGrabberProps extends ViewProps {
* Little Grabber component.
* Used by defualt for Android but feel free to re-use.
*/
export const TrueSheetGrabber = (props: TrueSheetGrabberProps) => {
export const TrueSheetGrabber = memo((props: TrueSheetGrabberProps) => {
const {
visible = true,
color = GRABBER_DEFAULT_COLOR,
Expand All @@ -53,7 +53,9 @@ export const TrueSheetGrabber = (props: TrueSheetGrabberProps) => {
<View style={[$grabber, { height, width, backgroundColor: color }, style]} {...rest} />
</View>
)
}
})

TrueSheetGrabber.displayName = 'TrueSheetGrabber'

const $wrapper: ViewStyle = {
position: 'absolute',
Expand Down

0 comments on commit f258213

Please sign in to comment.