Skip to content

Commit dc53661

Browse files
authored
Merge pull request #1 from orinamio/improve-submit-button
refactor: use correct prop typing for SubmitButton text input props
2 parents 37d5034 + 670508b commit dc53661

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,11 @@ export default function App() {
7878
</View>
7979

8080
<SubmitButton
81-
title="Pay Now"
8281
style={styles.button}
83-
textStyle={styles.buttonText}
82+
textInputProps={{
83+
title: "Pay Now",
84+
style: styles.buttonText,
85+
}}
8486
onPress={() => console.log("merchant action")}
8587
/>
8688
</Frames>

src/components/SubmitButton.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ const SubmitButton: React.FunctionComponent<SubmitButtonProps> = (props) => {
1111
throw "It looks like you are trying to render the SubmitButton outside of the Frames Component.";
1212
}
1313

14-
const { textStyle: textStyle, title: title, ...touchableProps } = props;
14+
const { textInputProps = {}, ...touchableProps } = props;
15+
const { title } = textInputProps;
1516

1617
return (
1718
<TouchableOpacity
@@ -22,7 +23,7 @@ const SubmitButton: React.FunctionComponent<SubmitButtonProps> = (props) => {
2223
if (props.onPress) props.onPress(e);
2324
}}
2425
>
25-
<Text style={[styles.buttonText, textStyle]}>{title}</Text>
26+
<Text {...textInputProps} style={[styles.buttonText, textInputProps.style]}>{title}</Text>
2627
</TouchableOpacity>
2728
);
2829
}}

src/types/types.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,5 @@ export interface CardBinChangedEvent {
194194
}
195195

196196
export interface SubmitButtonProps extends TouchableOpacityProps {
197-
title: string;
198-
textStyle?: TextProps;
197+
textInputProps?: TextInputProps;
199198
}

0 commit comments

Comments
 (0)