Skip to content

Commit

Permalink
add memo for app button and app input (#130)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mohan29997 committed Apr 13, 2023
1 parent 5563069 commit 81e27c2
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/mobile/src/feature/firstscreen/first_screen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { View, Image, Text, TouchableOpacity } from 'react-native'
import Images from '../../assets/images'
import i18n from 'localisation'
import style from './first_screen_style'
import { AppButton } from '../../widgets/app_button/app_button'
import AppButton from '../../widgets/app_button/app_button'
import { useTheme } from '../../theme/themeprovider'

const FirstScreen = () => {
Expand Down
5 changes: 4 additions & 1 deletion packages/mobile/src/widgets/app_button/app_button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ import i18n from 'localisation'
import LinearGradient from 'react-native-linear-gradient'
import Colors from '../../utils/color'
import { useTheme } from '../../theme/themeprovider'
import { memo } from 'react'

export type AppButtonProps = {
loadingState?: boolean
value: string
saveData?: () => void
}

export const AppButton = ({ loadingState, value, saveData }: AppButtonProps) => {
const AppButton = ({ loadingState, value, saveData }: AppButtonProps) => {
const { theme } = useTheme()
return (
<LinearGradient colors={[theme.primaryColor, theme.primaryColor]} style={style.buttonView}>
Expand All @@ -26,3 +27,5 @@ export const AppButton = ({ loadingState, value, saveData }: AppButtonProps) =>
</LinearGradient>
)
}

export default memo(AppButton, (prev, next) => prev.loadingState == next.loadingState)
5 changes: 4 additions & 1 deletion packages/mobile/src/widgets/app_input/app_input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ import Colors from '../../utils/color'
import style from './app_input_style'
import i18n from 'localisation'
import { useTheme } from '../../theme/themeprovider'
import { memo } from 'react'
export type AppInputProps = {
placeholderText: string
value: string
setData?: (e: string) => void
secure?: boolean
}

export const AppInput = ({ placeholderText, value, setData, secure }: AppInputProps) => {
const AppInput = ({ placeholderText, value, setData, secure }: AppInputProps) => {
const { theme } = useTheme()
return (
<TextInput
Expand All @@ -23,3 +24,5 @@ export const AppInput = ({ placeholderText, value, setData, secure }: AppInputPr
/>
)
}

export default memo(AppInput, (prev, next) => prev.value == next.value)

0 comments on commit 81e27c2

Please sign in to comment.