From e56852fde0c3327b7f0e9b1167b7332270b72de6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?namkyu=20koo=28=EA=B5=AC=EB=82=A8=EA=B7=9C=29?= <73378472+nain93@users.noreply.github.com> Date: Wed, 10 Aug 2022 21:48:43 +0900 Subject: [PATCH] =?UTF-8?q?=EC=B9=B4=EC=B9=B4=EC=98=A4=EB=A1=9C=EA=B7=B8?= =?UTF-8?q?=EC=9D=B8=20=EC=9B=B9=20=ED=95=A8=EC=88=98=20=EC=B6=94=EA=B0=80?= =?UTF-8?q?=20(#319)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * refactor: orgnize sourcecode in `src` directory Since there is more than a file now by including the web platform code, it is quite a mess to include them in config files like tsconfig, gitignore or npmignore. I have managed to place the typescript code that should be compiled in a `src` directory so that we can have less configuration. * build: fix build path for flowgen * refactor: cleanup codebase * 5.0.0 Co-authored-by: hyochan --- .eslintignore | 2 + .eslintrc.js | 6 +- .gitignore | 8 +- .npmignore | 3 +- .prettierrc.js | 1 - KakaoLoginExample/.eslintrc.js | 7 +- KakaoLoginExample/.gitignore | 5 - KakaoLoginExample/.prettierrc.js | 1 - KakaoLoginExample/@types/fbt/globals.d.ts | 92 - KakaoLoginExample/README.md | 10 - KakaoLoginExample/babel.config.js | 16 +- KakaoLoginExample/craco.config.js | 15 - KakaoLoginExample/package.json | 25 +- KakaoLoginExample/src/App.tsx | 10 +- .../navigations/RootStackNavigator.tsx | 28 +- .../__tests__/RootStackNavigator.test.tsx | 51 - .../RootStackNavigator.test.tsx.snap | 1339 --- .../src/components/pages/Intro.tsx | 46 +- .../src/components/pages/Temp.tsx | 7 +- .../components/pages/__tests__/Intro.test.tsx | 73 - .../components/pages/__tests__/Temp.test.tsx | 79 - .../__snapshots__/Intro.test.tsx.snap | 1501 ---- .../__snapshots__/Temp.test.tsx.snap | 139 - .../components/uis/Button/ButtonDisabled.tsx | 1 - .../components/uis/Button/ButtonLoading.tsx | 2 +- .../components/uis/Button/ButtonWrapper.tsx | 5 +- .../src/components/uis/Button/index.tsx | 1 - .../src/components/uis/IntroTemp.tsx | 3 +- .../src/components/uis/Styles.ts | 2 - .../src/components/uis/Typography.ts | 3 - .../components/uis/__tests__/Button.test.tsx | 99 - .../uis/__tests__/IntroTemp.test.tsx | 28 - .../__snapshots__/Button.test.tsx.snap | 137 - .../__snapshots__/IntroTemp.test.tsx.snap | 44 - KakaoLoginExample/src/index.tsx | 6 - .../src/providers/AppProvider.tsx | 95 - .../providers/__tests__/AppProvider.test.tsx | 93 - .../__snapshots__/AppProvider.test.tsx.snap | 71 - KakaoLoginExample/src/providers/index.tsx | 29 - KakaoLoginExample/src/utils/fbt.ts | 49 - .../src/utils/i18n/FbtI18nNativeAssets.js | 50 - .../src/utils/i18n/NativeFbtModule.js | 32 - .../src/utils/i18n/fbt/translatedFbts.json | 1 - .../src/utils/i18n/getTranslatedInput.js | 42 - .../generate-android-localizables-executor.js | 71 - .../scripts/generate-android-localizables.js | 87 - KakaoLoginExample/src/utils/theme.ts | 57 - KakaoLoginExample/src/utils/wrapper.tsx | 5 +- KakaoLoginExample/test/jestSetup.ts | 3 - KakaoLoginExample/tsconfig.json | 2 +- KakaoLoginExample/yarn.lock | 7276 ++++++++--------- index.ts => index.native.ts | 0 package.json | 16 +- src/index.native.ts | 108 + src/index.ts | 109 + tsconfig.json | 2 +- yarn.lock | 572 +- 57 files changed, 4168 insertions(+), 8397 deletions(-) create mode 100644 .eslintignore delete mode 100644 KakaoLoginExample/@types/fbt/globals.d.ts delete mode 100644 KakaoLoginExample/craco.config.js delete mode 100644 KakaoLoginExample/src/components/navigations/__tests__/RootStackNavigator.test.tsx delete mode 100644 KakaoLoginExample/src/components/navigations/__tests__/__snapshots__/RootStackNavigator.test.tsx.snap delete mode 100644 KakaoLoginExample/src/components/pages/__tests__/Intro.test.tsx delete mode 100644 KakaoLoginExample/src/components/pages/__tests__/Temp.test.tsx delete mode 100644 KakaoLoginExample/src/components/pages/__tests__/__snapshots__/Intro.test.tsx.snap delete mode 100644 KakaoLoginExample/src/components/pages/__tests__/__snapshots__/Temp.test.tsx.snap delete mode 100644 KakaoLoginExample/src/components/uis/__tests__/Button.test.tsx delete mode 100644 KakaoLoginExample/src/components/uis/__tests__/IntroTemp.test.tsx delete mode 100644 KakaoLoginExample/src/components/uis/__tests__/__snapshots__/Button.test.tsx.snap delete mode 100644 KakaoLoginExample/src/components/uis/__tests__/__snapshots__/IntroTemp.test.tsx.snap delete mode 100644 KakaoLoginExample/src/providers/AppProvider.tsx delete mode 100644 KakaoLoginExample/src/providers/__tests__/AppProvider.test.tsx delete mode 100644 KakaoLoginExample/src/providers/__tests__/__snapshots__/AppProvider.test.tsx.snap delete mode 100644 KakaoLoginExample/src/providers/index.tsx delete mode 100644 KakaoLoginExample/src/utils/fbt.ts delete mode 100644 KakaoLoginExample/src/utils/i18n/FbtI18nNativeAssets.js delete mode 100644 KakaoLoginExample/src/utils/i18n/NativeFbtModule.js delete mode 100644 KakaoLoginExample/src/utils/i18n/fbt/translatedFbts.json delete mode 100644 KakaoLoginExample/src/utils/i18n/getTranslatedInput.js delete mode 100644 KakaoLoginExample/src/utils/i18n/scripts/generate-android-localizables-executor.js delete mode 100644 KakaoLoginExample/src/utils/i18n/scripts/generate-android-localizables.js delete mode 100644 KakaoLoginExample/src/utils/theme.ts rename index.ts => index.native.ts (100%) create mode 100644 src/index.native.ts create mode 100644 src/index.ts diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 0000000..2883e1e --- /dev/null +++ b/.eslintignore @@ -0,0 +1,2 @@ +src/**/*.js +src/**/*.d.ts \ No newline at end of file diff --git a/.eslintrc.js b/.eslintrc.js index f1e3fad..4038df7 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,4 +1,8 @@ module.exports = { root: true, - extends: "@dooboo/eslint-config", + extends: "@dooboo/eslint-config-react-native", + settings: { + react: {version: 'detect'}, + jest: {version: 26}, + }, }; diff --git a/.gitignore b/.gitignore index 3418afc..63d5ab1 100644 --- a/.gitignore +++ b/.gitignore @@ -45,10 +45,12 @@ buck-out/ \.buckd/ *.keystore -index.js -index.d.ts -index.js.flow +# Built files +src/**/*.js +src/**/*.d.ts +src/**/*.js.flow # iOS ios/Pods +.watchman* \ No newline at end of file diff --git a/.npmignore b/.npmignore index a06d9c9..14933df 100644 --- a/.npmignore +++ b/.npmignore @@ -5,4 +5,5 @@ node_modules/ KakaoLoginExample/ image/ -index.ts \ No newline at end of file +src/**/*.ts +!src/**/*.d.ts \ No newline at end of file diff --git a/.prettierrc.js b/.prettierrc.js index fe9e87f..18c387b 100644 --- a/.prettierrc.js +++ b/.prettierrc.js @@ -4,6 +4,5 @@ module.exports = { arrowParens: "always", singleQuote: true, jsxSingleQuote: false, - jsxBracketSameLine: true, bracketSpacing: false, }; diff --git a/KakaoLoginExample/.eslintrc.js b/KakaoLoginExample/.eslintrc.js index ed0e10a..2ecc980 100644 --- a/KakaoLoginExample/.eslintrc.js +++ b/KakaoLoginExample/.eslintrc.js @@ -1,8 +1,13 @@ module.exports = { root: true, - extends: '@dooboo/eslint-config', + extends: '@dooboo/eslint-config-react-native', rules: { 'eslint-comments/no-unlimited-disable': 0, 'eslint-comments/no-unused-disable': 0, }, + settings: { + react: { + version: 'detect', + }, + }, }; diff --git a/KakaoLoginExample/.gitignore b/KakaoLoginExample/.gitignore index f3b5669..8dcc96c 100644 --- a/KakaoLoginExample/.gitignore +++ b/KakaoLoginExample/.gitignore @@ -66,8 +66,3 @@ package-lock.json ios/Pods/ -# fbt -src/utils/i18n/fbt/.enum_manifest.json -src/utils/i18n/fbt/.source_strings.json -src/utils/i18n/fbt/.src_manifest.json - diff --git a/KakaoLoginExample/.prettierrc.js b/KakaoLoginExample/.prettierrc.js index fe9e87f..18c387b 100644 --- a/KakaoLoginExample/.prettierrc.js +++ b/KakaoLoginExample/.prettierrc.js @@ -4,6 +4,5 @@ module.exports = { arrowParens: "always", singleQuote: true, jsxSingleQuote: false, - jsxBracketSameLine: true, bracketSpacing: false, }; diff --git a/KakaoLoginExample/@types/fbt/globals.d.ts b/KakaoLoginExample/@types/fbt/globals.d.ts deleted file mode 100644 index 6a4506e..0000000 --- a/KakaoLoginExample/@types/fbt/globals.d.ts +++ /dev/null @@ -1,92 +0,0 @@ -/// - -declare namespace FBT { - type $Values = T[keyof T]; - - // https://github.com/facebookincubator/fbt/blob/e9c591f451dbfc91852e316869ae39ad41848c55/runtime/nonfb/GenderConst.js#L9-L23 - interface GenderConst { - NOT_A_PERSON: 0; - FEMALE_SINGULAR: 1; - MALE_SINGULAR: 2; - FEMALE_SINGULAR_GUESS: 3; - MALE_SINGULAR_GUESS: 4; - MIXED_SINGULAR: 5; - MIXED_PLURAL: 5; - NEUTER_SINGULAR: 6; - UNKNOWN_SINGULAR: 7; - FEMALE_PLURAL: 8; - MALE_PLURAL: 9; - NEUTER_PLURAL: 10; - UNKNOWN_PLURAL: 11; - } - - interface IntlVariationsGender { - GENDER_MALE: 1; - GENDER_FEMALE: 2; - GENDER_UNKNOWN: 3; - } - - // https://github.com/facebookincubator/fbt/blob/e9c591f451dbfc91852e316869ae39ad41848c55/runtime/nonfb/IntlVariations.js#L9-L21 - interface IntlVariations extends IntlVariationsGender { - BITMASK_NUMBER: 28; - BITMASK_GENDER: 3; - NUMBER_ZERO: 16; - NUMBER_ONE: 4; - NUMBER_TWO: 8; - NUMBER_FEW: 20; - NUMBER_MANY: 12; - NUMBER_OTHER: 24; - } - - // https://github.com/facebookincubator/fbt/blob/c2d363a40b622d5aaf80ff1d249b38604fd869f6/transform/babel-plugin-fbt/FbtConstants.js#L22-L27 - type PronounType = 'object' | 'possessive' | 'reflexive' | 'subject'; - - type IntlVariationsGenderValues = $Values; - - interface IntlViewerContext { - GENDER: IntlVariationsGenderValues; - locale: string; - } - - type IntlVariationsValues = $Values; - type GenderConstValues = $Values; - - type Translations = {[locale: string]: {[key: string]: string}}; - - interface Options { - author?: string; - common?: boolean; - doNotExtract?: boolean; - preserveWhitespace?: boolean; - project?: string; - subject?: IntlVariationsGenderValues; - } - - interface PluralOptions { - many?: string; - showCount?: 'yes' | 'no' | 'ifMany'; - name?: string; - value?: any; - } - - interface ParamOptions { - gender?: IntlVariationsGenderValues; - number?: number | true; - } - - interface PronounOptions { - human?: boolean; - capitalize?: boolean; - } - - type FbtResult = string; -} - -declare namespace JSX { - interface IntrinsicElements { - fbt: { - desc: string; - children: React.ReactNode | React.ReactNode[]; - } & FBT.Options; - } -} diff --git a/KakaoLoginExample/README.md b/KakaoLoginExample/README.md index 3d4a43b..199b535 100644 --- a/KakaoLoginExample/README.md +++ b/KakaoLoginExample/README.md @@ -12,7 +12,6 @@ DO NOT MODIFY OR CHANGE THE CODE BEFORE CONFIRMED BY `DOOBOOLAB`. THIS REPOSITOR - [react-native](https://github.com/facebook/react-native) - [react-navigation](https://github.com/react-navigation/react-navigation) - [typescript](https://github.com/Microsoft/TypeScript) -- [fbt](https://medium.com/dooboolab/localizing-react-app-with-fbt-instead-of-i18n-90822e0cb373) - [styled-components](https://github.com/styled-components/styled-components) - [ts-jest](https://github.com/kulshekhar/ts-jest) - [react-hook](https://reactjs.org/docs/hooks-intro.html) @@ -196,12 +195,3 @@ const component = (props): React.ReactElement => { > using consistent theme(ThemeType.LIGHT as default) explicitly is encouraged in testing for avoiding unexpected snapshot test errors -### Localization - -Previously, we used `i18n-j` to localize our app and we decided to switch to [fbt](https://github.com/facebook/fbt). If you want to understand why, you may see our blog for [Localizing react app with FBT instead of src/utils/i18n](https://medium.com/dooboolab/localizing-react-app-with-fbt-instead-of-i18n-90822e0cb373). - -We've defined localized strings in `assets/translations/en.json` for English and `assets/translations/ko.json` for Korean. Since the `en` is default locale setup in current project, you do not need to localize this file. However, you still should not delete this if you don't want to see missing localization warning messages when you are running jest. - -We are using [fbt](https://github.com/facebook/fbt) to localize our app which is maintained by Facebook team. Simply running `yarn fbt:all` will generate `i18n/fbt/translatedFbts.json` which has all the localized strings. - -If you find trouble using it, you may follow [Integrate FBT into your React Native Application](https://medium.com/translate-your-react-native-application-with/integrate-fbt-into-your-react-native-application-2bac420e8e0c). diff --git a/KakaoLoginExample/babel.config.js b/KakaoLoginExample/babel.config.js index c7fc3e7..d02c096 100644 --- a/KakaoLoginExample/babel.config.js +++ b/KakaoLoginExample/babel.config.js @@ -1,24 +1,10 @@ // eslint-disable-next-line const path = require('path'); -const fbtEnumPath = path.join( - __dirname, - 'src/utils/i18n/fbt/.enum_manifest.json', -); - module.exports = { presets: [ 'module:metro-react-native-babel-preset', '@babel/preset-typescript', ], - plugins: [ - 'babel-plugin-fbt-runtime', - [ - 'babel-plugin-fbt', - { - fbtEnumPath, - extraOptions: {__self: true}, - }, - ], - ], + plugins: [], }; diff --git a/KakaoLoginExample/craco.config.js b/KakaoLoginExample/craco.config.js deleted file mode 100644 index e1cc3e2..0000000 --- a/KakaoLoginExample/craco.config.js +++ /dev/null @@ -1,15 +0,0 @@ -module.exports = { - babel: { - presets: ['@babel/preset-typescript'], - plugins: [ - [ - 'babel-plugin-fbt', - { - fbtEnumManifest: require('./src/utils/i18n/fbt/.enum_manifest.json'), - extraOptions: {__self: true}, - }, - ], - 'babel-plugin-fbt-runtime', - ], - }, -}; diff --git a/KakaoLoginExample/package.json b/KakaoLoginExample/package.json index b024ac4..d05fd7f 100644 --- a/KakaoLoginExample/package.json +++ b/KakaoLoginExample/package.json @@ -7,7 +7,6 @@ "postinstall": "npx jetify", "scripts": { "preinstall": "cd .. && yarn install && yarn build", - "postinstall": "yarn fbt:all", "dev": "react-native start", "tsc": "tsc", "watch": "tsc -w", @@ -18,8 +17,7 @@ "test": "jest --runInBand", "start:packager": "node_modules/react-native/packager/packager.sh", "start:reset": "react-native start --reset-cache", - "web": "craco start", - "build": "craco build", + "web": "SKIP_PREFLIGHT_CHECK=true react-scripts start", "reset": "watchman watch-del-all; rm -rf /tmp/metro-bundler-cache-*; rm -rf ./android/build; rm -rf ./android/.gradle; rm -rf ./android/app/build; rm -rf ~/Library/Developer/Xcode/DerivedData; rm -rf /tmp/haste-map-react-native-packager-*; rm -rf ./ios/build; jest --clearCache; cd ios; pod install --repo-update; cd ..; npx jetify; cd android; ./gradlew clean; cd ..; react-native start --reset-cache", "android": "react-native run-android", "android:shake": "adb shell input keyevent 82", @@ -36,13 +34,7 @@ "ios:reset": "rm -rf ios/build/ModuleCache", "lint": "eslint src --ext .ts,.tsx,.js,.jsx", "build:ios": "react-native bundle --entry-file index.js --platform ios --dev false --bundle-output ios/main.jsbundle --assets-dest ./ios", - "build:android": "react-native bundle --entry-file index.js --platform android --dev false --bundle-output android/main.jsbundle --assets-dest ./android", - "manifest": "fbt-manifest --src src/ --enum-manifest src/utils/i18n/fbt/.enum_manifest.json --src-manifest src/utils/i18n/fbt/.src_manifest.json", - "collect-fbts": "fbt-collect --hash-module 'fb-tiger-hash/src/hashPhrases' --react-native-mode --manifest --options __self < src/utils/i18n/fbt/.src_manifest.json > src/utils/i18n/fbt/.source_strings.json", - "translate-fbts": "fbt-translate --jenkins --source-strings src/utils/i18n/fbt/.source_strings.json --translations src/assets/translations/*.json > src/utils/i18n/fbt/translatedFbts.json", - "clean-fbts": "rm src/utils/i18n/fbt/.enum_manifest.json src/utils/i18n/fbt/.src_manifest.json src/utils/i18n/fbt/.source_strings.json src/assets/translatedFbts.json 2&> /dev/null || exit 0", - "fbt:android": "babel-node src/utils/i18n/scripts/generate-android-localizables-executor.js", - "fbt:all": "yarn manifest && yarn collect-fbts && yarn translate-fbts && yarn fbt:android" + "build:android": "react-native bundle --entry-file index.js --platform android --dev false --bundle-output android/main.jsbundle --assets-dest ./android" }, "dependencies": { "@react-native-community/async-storage": "^1.12.1", @@ -51,8 +43,6 @@ "@react-navigation/core": "^5.15.3", "@react-navigation/native": "^5.9.4", "@react-navigation/stack": "^5.14.4", - "dooboo-ui": "0.0.51", - "fbt": "^0.16.5", "react": "17.0.2", "react-native": "0.64.1", "react-native-gesture-handler": "^1.10.3", @@ -72,31 +62,26 @@ "@babel/plugin-syntax-jsx": "^7.12.13", "@babel/preset-typescript": "^7.13.0", "@babel/runtime": "^7.14.0", - "@craco/craco": "^6.1.2", - "@dooboo/eslint-config": "^0.7.0", + "@dooboo/eslint-config-react-native": "^1.0.0", "@testing-library/jest-native": "^4.0.1", "@testing-library/react-native": "^7.2.0", "@types/jest": "^26.0.23", "@types/react": "^17.0.4", - "@types/react-native": "^0.64.4", + "@types/react-native": "^0.64", "@types/react-responsive": "^8.0.2", "@types/styled-components": "^5.1.9", - "@types/styled-components-react-native": "^5.1.1", + "@types/styled-components-react-native": "^5.1.3", "babel-jest": "^26.6.3", - "babel-plugin-fbt": "^0.20.0", - "babel-plugin-fbt-runtime": "^0.9.17", "babel-preset-react-native": "^4.0.1", "codecov": "^3.8.1", "eslint": "^7.25.0", "fb-tiger-hash": "^0.1.6", - "fbt-generate-translations": "^0.0.4", "jest-fetch-mock": "^3.0.3", "jest-styled-components": "^7.0.4", "jetifier": "^1.6.6", "metro-react-native-babel-preset": "^0.64.0", "prettier": "^2.2.1", "react-dom": "^17.0.2", - "react-native-fbt": "^0.0.2", "react-test-renderer": "^17.0.2", "ts-jest": "^26.5.5", "typescript": "4.2.4" diff --git a/KakaoLoginExample/src/App.tsx b/KakaoLoginExample/src/App.tsx index 532e273..279576f 100644 --- a/KakaoLoginExample/src/App.tsx +++ b/KakaoLoginExample/src/App.tsx @@ -1,20 +1,12 @@ import React from 'react'; import RootNavigator from './components/navigations/RootStackNavigator'; -import RootProvider from './providers'; -import {initFbt} from './utils/fbt'; - -initFbt(); function App(): React.ReactElement { return ; } function ProviderWrapper(): React.ReactElement { - return ( - - - - ); + return ; } export default ProviderWrapper; diff --git a/KakaoLoginExample/src/components/navigations/RootStackNavigator.tsx b/KakaoLoginExample/src/components/navigations/RootStackNavigator.tsx index 994a78d..23bff01 100644 --- a/KakaoLoginExample/src/components/navigations/RootStackNavigator.tsx +++ b/KakaoLoginExample/src/components/navigations/RootStackNavigator.tsx @@ -7,7 +7,6 @@ import Intro from '../pages/Intro'; import {NavigationContainer} from '@react-navigation/native'; import React from 'react'; import Temp from '../pages/Temp'; -import {useTheme} from 'dooboo-ui'; export type RootStackParamList = { default: undefined; @@ -16,36 +15,25 @@ export type RootStackParamList = { }; export type RootStackNavigationProps< - T extends keyof RootStackParamList = 'default' + T extends keyof RootStackParamList = 'default', > = StackNavigationProp; const Stack = createStackNavigator(); function RootNavigator(): React.ReactElement { - const {theme} = useTheme(); - return ( - + + {/* @ts-ignore */} + headerTitleStyle: {color: 'black'}, + headerTintColor: 'yellow', + }} + > diff --git a/KakaoLoginExample/src/components/navigations/__tests__/RootStackNavigator.test.tsx b/KakaoLoginExample/src/components/navigations/__tests__/RootStackNavigator.test.tsx deleted file mode 100644 index 0ddaad2..0000000 --- a/KakaoLoginExample/src/components/navigations/__tests__/RootStackNavigator.test.tsx +++ /dev/null @@ -1,51 +0,0 @@ -import 'react-native'; - -import React, {ReactElement} from 'react'; -import {RenderAPI, cleanup, render} from '@testing-library/react-native'; -import {createTestElement, createTestProps} from '../../../../test/testUtils'; - -import StackNavigator from '../RootStackNavigator'; -import {ThemeType} from 'dooboo-ui'; - -let props: any; -let component: ReactElement; -let testingLib: RenderAPI; - -describe('[Stack] navigator', () => { - beforeEach(() => { - props = createTestProps(); - - component = createTestElement(); - }); - - afterEach(cleanup); - - it('should renders without crashing', () => { - jest.useFakeTimers(); - - testingLib = render(component); - - const baseElement = testingLib.toJSON(); - - jest.runAllTimers(); - expect(baseElement).toMatchSnapshot(); - expect(baseElement).toBeTruthy(); - }); - - it('should renders [Dark] mode', () => { - jest.useFakeTimers(); - - component = createTestElement( - , - ThemeType.DARK, - ); - - testingLib = render(component); - - const baseElement = testingLib.toJSON(); - - jest.runAllTimers(); - expect(baseElement).toMatchSnapshot(); - expect(baseElement).toBeTruthy(); - }); -}); diff --git a/KakaoLoginExample/src/components/navigations/__tests__/__snapshots__/RootStackNavigator.test.tsx.snap b/KakaoLoginExample/src/components/navigations/__tests__/__snapshots__/RootStackNavigator.test.tsx.snap deleted file mode 100644 index d63b976..0000000 --- a/KakaoLoginExample/src/components/navigations/__tests__/__snapshots__/RootStackNavigator.test.tsx.snap +++ /dev/null @@ -1,1339 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`[Stack] navigator should renders [Dark] mode 1`] = ` - - - - - - - - - - - - - Intro - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 카카오 로그인 - - - - - - - - - 프로필 조회 - - - - - - - - - 링크 해제 - - - - - - - - - 카카오 로그아웃 - - - - - - - - - - - - - - - - - -`; - -exports[`[Stack] navigator should renders without crashing 1`] = ` - - - - - - - - - - - - - Intro - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 카카오 로그인 - - - - - - - - - 프로필 조회 - - - - - - - - - 링크 해제 - - - - - - - - - 카카오 로그아웃 - - - - - - - - - - - - - - - - - -`; diff --git a/KakaoLoginExample/src/components/pages/Intro.tsx b/KakaoLoginExample/src/components/pages/Intro.tsx index 109898f..bd3d0dd 100644 --- a/KakaoLoginExample/src/components/pages/Intro.tsx +++ b/KakaoLoginExample/src/components/pages/Intro.tsx @@ -1,12 +1,10 @@ +import React, {useState} from 'react'; import { - KakaoOAuthToken, - KakaoProfile, getProfile as getKakaoProfile, login, logout, unlink, } from '@react-native-seoul/kakao-login'; -import React, {useState} from 'react'; import Button from '../uis/Button'; import {IC_MASK} from '../../utils/Icons'; @@ -19,7 +17,7 @@ const Container = styled.View` flex: 1; align-self: stretch; overflow: scroll; - background-color: ${({theme}) => theme.background}; + background-color: white; flex-direction: column; justify-content: flex-start; @@ -39,27 +37,47 @@ function Intro(): React.ReactElement { const [result, setResult] = useState(''); const signInWithKakao = async (): Promise => { - const token: KakaoOAuthToken = await login(); + try { + const token = await login(); - setResult(JSON.stringify(token)); + setResult(JSON.stringify(token)); + } catch (err) { + // eslint-disable-next-line no-console + console.error('login err', err); + } }; const signOutWithKakao = async (): Promise => { - const message = await logout(); + try { + const message = await logout(); - setResult(message); + setResult(message); + } catch (err) { + // eslint-disable-next-line no-console + console.error('signOut error', err); + } }; const getProfile = async (): Promise => { - const profile: KakaoProfile = await getKakaoProfile(); + try { + const profile = await getKakaoProfile(); - setResult(JSON.stringify(profile)); + setResult(JSON.stringify(profile)); + } catch (err) { + // eslint-disable-next-line no-console + console.error('signOut error', err); + } }; const unlinkKakao = async (): Promise => { - const message = await unlink(); + try { + const message = await unlink(); - setResult(message); + setResult(message); + } catch (err) { + // eslint-disable-next-line no-console + console.error('signOut error', err); + } }; return ( @@ -81,6 +99,7 @@ function Intro(): React.ReactElement { onPress={() => signInWithKakao()} text={'카카오 로그인'} /> + {/* @ts-ignore */}