Skip to content

Commit

Permalink
fixed crash when running app for the first time and no include text i…
Browse files Browse the repository at this point in the history
…s set
  • Loading branch information
josippapez committed May 11, 2022
1 parent d6e38f6 commit 9696996
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 84 deletions.
110 changes: 55 additions & 55 deletions App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import {setBody, setIncludes, setPhoneNumber} from './store/reducers/settings';
import Images from './Styles/Images/index';

type SectionProps = {
children?: String;
children?: string;
title: string;
boldedTitle?: boolean;
sectionStyle?: ViewStyle;
Expand All @@ -61,7 +61,7 @@ export const Section = (props: SectionProps): JSX.Element => {
]}>
{title}
</Text>
{children && (
{children ? (
<Text
style={[
styles.sectionDescription,
Expand All @@ -71,7 +71,7 @@ export const Section = (props: SectionProps): JSX.Element => {
]}>
{children}
</Text>
)}
) : null}
</View>
);
};
Expand Down Expand Up @@ -188,57 +188,57 @@ const App: () => JSX.Element = () => {
title="Message includes...">
Includes any of the inputs
</Section>
{filterInput.includes &&
filterInput.includes.length > 0 &&
filterInput.includes.map((item, index) => (
<View
key={index}
style={{
flexDirection: 'row',
marginTop: index > 0 ? 10 : 0,
}}>
<TextInput
style={inputBackgroundStyle}
value={item}
onChangeText={text =>
setFilterInput({
...filterInput,
includes: [
...filterInput.includes.slice(0, index),
text,
...filterInput.includes.slice(index + 1),
],
})
}
/>
<CustomButton
cb={() =>
setFilterInput(
filterInput.includes.length > 0
? {
...filterInput,
includes: [
...filterInput.includes.slice(0, index),
...filterInput.includes.slice(index + 1),
],
}
: filterInput,
)
}
backgroundimage={{
image: isDarkMode ? Images.minusWhite : Images.minus,
style: {
width: 30,
height: 30,
},
}}
buttonStyle={{
marginLeft: 15,
}}
/>
</View>
))}
{filterInput.includes && filterInput.includes.length < 7 && (
{filterInput.includes && filterInput.includes.length > 0
? filterInput.includes.map((item, index) => (
<View
key={index}
style={{
flexDirection: 'row',
marginTop: index > 0 ? 10 : 0,
}}>
<TextInput
style={inputBackgroundStyle}
value={item}
onChangeText={text =>
setFilterInput({
...filterInput,
includes: [
...filterInput.includes.slice(0, index),
text,
...filterInput.includes.slice(index + 1),
],
})
}
/>
<CustomButton
cb={() =>
setFilterInput(
filterInput.includes.length > 0
? {
...filterInput,
includes: [
...filterInput.includes.slice(0, index),
...filterInput.includes.slice(index + 1),
],
}
: filterInput,
)
}
backgroundimage={{
image: isDarkMode ? Images.minusWhite : Images.minus,
style: {
width: 30,
height: 30,
},
}}
buttonStyle={{
marginLeft: 15,
}}
/>
</View>
))
: null}
{filterInput.includes && filterInput.includes.length < 7 ? (
<CustomButton
buttonStyle={{
marginTop: 20,
Expand All @@ -264,7 +264,7 @@ const App: () => JSX.Element = () => {
},
}}
/>
)}
) : null}
</View>
<View
style={{
Expand Down
55 changes: 29 additions & 26 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
"dependencies": {
"@react-native-async-storage/async-storage": "^1.17.3",
"@reduxjs/toolkit": "^1.8.1",
"@types/react-native": "^0.67.3",
"@types/react-redux": "^7.1.23",
"react": "17.0.2",
"react-native": "0.68.0",
"react-native-android-sms-listener": "^0.8.0",
Expand All @@ -27,6 +25,9 @@
"@babel/core": "^7.12.9",
"@babel/runtime": "^7.12.5",
"@react-native-community/eslint-config": "^2.0.0",
"@types/react": "^18.0.9",
"@types/react-native": "^0.67.6",
"@types/react-redux": "^7.1.24",
"babel-jest": "^26.6.3",
"eslint": "^7.32.0",
"jest": "^26.6.3",
Expand Down
2 changes: 1 addition & 1 deletion store/reducers/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export interface SettingsState {
}

const initialState: SettingsState = {
includes: [],
includes: [''],
phoneNumber: '',
body: '',
};
Expand Down

0 comments on commit 9696996

Please sign in to comment.