Skip to content

Commit

Permalink
Merge pull request #987 from UNICEFECAR/fixImportIssue-208952
Browse files Browse the repository at this point in the history
Reverted the package and metro config file to address the SVG
  • Loading branch information
deepakmali-dgsl authored Jul 30, 2024
2 parents e0677d3 + a385a3c commit 34572c0
Show file tree
Hide file tree
Showing 4 changed files with 170 additions and 21,712 deletions.
25 changes: 10 additions & 15 deletions app/screens/home/SettingScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -150,20 +150,15 @@ const SettingScreen = (props: any): any => {
const actionSheetRef = createRef<any>();
const actionSheetRefImport = createRef<any>();
const countryId = useAppSelector(
(state: any) => state.selectedCountry.countryId,
(state: any) => state.selectedCountry?.countryId,
);
const allCountries = useAppSelector(
(state: any) => {
try {
state.selectedCountry.countries !== '' ? JSON.parse(state.selectedCountry.countries) : [];
} catch (error) {
console.error('Failed to parse countries JSON:', error);
return [];
}
});
(state: any) =>
state.selectedCountry.countries != '' ? JSON.parse(state.selectedCountry.countries) : [],
);
const [profileLoading, setProfileLoading] = React.useState(false);
const languageCode = useAppSelector(
(state: any) => state.selectedCountry.languageCode,
(state: any) => state.selectedCountry?.languageCode,
);
const netInfo = useNetInfoHook();
const weeklyDownloadDate = useAppSelector(
Expand Down Expand Up @@ -620,13 +615,13 @@ const SettingScreen = (props: any): any => {
setlanguage(allCountries[0]?.languages[0]);
} else {
console.log('Selected country for countryId is', countryId);
const selectedCountry: any = allCountries.find(
(country: any) => country.CountryID === countryId,
const selectedCountry: any = allCountries?.find(
(country: any) => country?.CountryID === countryId,
);
console.log('Selected country is', selectedCountry);
setCountry(selectedCountry);
const selectedLanguage: any = selectedCountry?.languages?.find(
(language: any) => language.languageCode === languageCode,
(language: any) => language?.languageCode === languageCode,
);
setlanguage(selectedLanguage);
}
Expand Down Expand Up @@ -1035,7 +1030,7 @@ const SettingScreen = (props: any): any => {
<Heading3Regular>{t('country')}</Heading3Regular>
</Flex2>
<Flex3>
<Heading3>{country.name}</Heading3>
<Heading3>{country?.name}</Heading3>
</Flex3>
</FDirRow>
</ShiftFromTopBottom5>
Expand All @@ -1045,7 +1040,7 @@ const SettingScreen = (props: any): any => {
<Heading3Regular>{t('language')}</Heading3Regular>
</Flex2>
<Flex3>
<Heading3>{language.displayName}</Heading3>
<Heading3>{language?.displayName}</Heading3>
</Flex3>
</FDirRow>
</ShiftFromTopBottom5>
Expand Down
37 changes: 16 additions & 21 deletions metro.config.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,26 @@
const { getDefaultConfig, mergeConfig } = require('@react-native/metro-config');
const {getDefaultConfig, mergeConfig} = require('@react-native/metro-config');

const defaultConfig = getDefaultConfig(__dirname);
const { assetExts, sourceExts } = defaultConfig.resolver;
/**
* Metro configuration
* https://facebook.github.io/metro/docs/configuration
*
* @type {import('metro-config').MetroConfig}
*/

const blacklist = require('metro-config/src/defaults/exclusionList');
const blacklist = require('metro-config/src/defaults/exclusionList')
const config = {
resetCache: true,
transformer: {
babelTransformerPath: require.resolve('react-native-svg-transformer/react-native'),
getTransformOptions: async () => ({
transform: {
experimentalImportSupport: false,
inlineRequires: true,
},
}),
},
resolver: {
resetCache: true,
transformer: {
getTransformOptions: async () => ({
transform: {
experimentalImportSupport: false,
inlineRequires: true,
},
}),
},
resolver: {
blacklistRE: blacklist([/xk\/.*/]),
assetExts: assetExts.filter((ext) => ext !== 'svg'),
sourceExts: [...sourceExts, 'svg'],
},
};

module.exports = mergeConfig(getDefaultConfig(__dirname), config);
}
};

module.exports = mergeConfig(getDefaultConfig(__dirname), config);
Loading

0 comments on commit 34572c0

Please sign in to comment.