diff --git a/.changeset/happy-rings-judge.md b/.changeset/happy-rings-judge.md new file mode 100644 index 00000000..94a2ab64 --- /dev/null +++ b/.changeset/happy-rings-judge.md @@ -0,0 +1,5 @@ +--- +'create-expo-stack': patch +--- + +Pass down props for button components diff --git a/cli/src/templates/base/components/Button.tsx.ejs b/cli/src/templates/base/components/Button.tsx.ejs index 9be358b8..c5d8249c 100644 --- a/cli/src/templates/base/components/Button.tsx.ejs +++ b/cli/src/templates/base/components/Button.tsx.ejs @@ -2,13 +2,12 @@ import { forwardRef } from 'react'; import { StyleSheet, Text, TouchableOpacity, TouchableOpacityProps } from 'react-native'; type ButtonProps = { - onPress?: TouchableOpacityProps['onPress']; title?: string; } & TouchableOpacityProps; -export const Button = forwardRef(({ onPress, title }, ref) => { +export const Button = forwardRef(({ title, ...touchableProps }, ref) => { return ( - + {title} ); diff --git a/cli/src/templates/packages/nativewind/components/Button.tsx.ejs b/cli/src/templates/packages/nativewind/components/Button.tsx.ejs index 3c25f8aa..b1e1a2e9 100644 --- a/cli/src/templates/packages/nativewind/components/Button.tsx.ejs +++ b/cli/src/templates/packages/nativewind/components/Button.tsx.ejs @@ -1,14 +1,13 @@ import { forwardRef } from 'react'; import { Text, TouchableOpacity, TouchableOpacityProps } from 'react-native'; -interface ButtonProps extends TouchableOpacityProps { - onPress?: () => void; +type ButtonProps = { title: string; -} +} & TouchableOpacityProps; -export const Button = forwardRef(({ onPress, title }, ref) => { +export const Button = forwardRef(({ title, ...touchableProps }, ref) => { return ( - + {title} ); diff --git a/cli/src/templates/packages/nativewindui/components/Button.tsx.ejs b/cli/src/templates/packages/nativewindui/components/Button.tsx.ejs index 9be358b8..c5d8249c 100644 --- a/cli/src/templates/packages/nativewindui/components/Button.tsx.ejs +++ b/cli/src/templates/packages/nativewindui/components/Button.tsx.ejs @@ -2,13 +2,12 @@ import { forwardRef } from 'react'; import { StyleSheet, Text, TouchableOpacity, TouchableOpacityProps } from 'react-native'; type ButtonProps = { - onPress?: TouchableOpacityProps['onPress']; title?: string; } & TouchableOpacityProps; -export const Button = forwardRef(({ onPress, title }, ref) => { +export const Button = forwardRef(({ title, ...touchableProps }, ref) => { return ( - + {title} ); diff --git a/cli/src/templates/packages/restyle/components/Button.tsx.ejs b/cli/src/templates/packages/restyle/components/Button.tsx.ejs index d8491078..c05f5d89 100644 --- a/cli/src/templates/packages/restyle/components/Button.tsx.ejs +++ b/cli/src/templates/packages/restyle/components/Button.tsx.ejs @@ -1,12 +1,16 @@ import { forwardRef } from 'react'; -import { TouchableOpacity } from 'react-native'; +import { TouchableOpacity, TouchableOpacityProps } from 'react-native'; import { Text, makeStyles } from 'theme'; -export const Button = forwardRef(({ onPress, title }, ref) => { +type ButtonProps = { + title?: string; +} & TouchableOpacityProps; + +export const Button = forwardRef(({ title, ...touchableProps }, ref) => { const styles = useStyles(); return ( - + {title} diff --git a/cli/src/templates/packages/unistyles/components/Button.tsx.ejs b/cli/src/templates/packages/unistyles/components/Button.tsx.ejs index 619e1332..5b9730a4 100644 --- a/cli/src/templates/packages/unistyles/components/Button.tsx.ejs +++ b/cli/src/templates/packages/unistyles/components/Button.tsx.ejs @@ -1,12 +1,17 @@ import { forwardRef } from 'react'; -import { Text, TouchableOpacity } from 'react-native'; +import { Text, TouchableOpacity, TouchableOpacityProps } from 'react-native'; import { useStyles } from 'react-native-unistyles'; -export const Button = forwardRef(({ onPress, title }, ref) => { +type ButtonProps = { + title?: string; +} & TouchableOpacityProps; + + +export const Button = forwardRef(({ title, ...touchableProps }, ref) => { const { theme } = useStyles(); return ( - + {title} );