본문 바로가기

coding59

[React] 함수의 재생성 방지해주는 useCallback로 퍼포먼스 향상하기 useCallback(callback, deps) useCallback은 함수를 의미없이 호출하는 것을 방지하기위해 캐싱해두는데, deps의 값들 중 하나라도 변경되었다면 그것을 감지해서 함수를 새로만든다. 바뀐게 없으면 이전에 만든 함수를 사용함. const onSubmit = useCallback((e)=>{ e.preventDefault(); console.log(email, nickname) }, [email, nickname]) 내부 변수(=e)는 선언할 필요가 거의 없고, 외부변수인 경우만 deps 추가해주도록한다. 2021. 9. 3.
[React] webpack.config.ts에서 이모션 바벨 플러그인 설정 const config: Configuration = { ... module: { rules: [ { options: { env: { development: { plugins: [['@emotion/babel-plugin',{sourceMap: true}]] }, production: { plugins: ['@emotion/bable-plugin'], } } } } ] } ... } 플러그인 설정은 [](배열)로 플러그인을 한번 감싸고 두번째 인자로 설정값을 입력하면 됨. - sourceMap: 활성화할 경우, 자바스크립트 파일의 스타일 선언으로 직접 이동함. 이모션 바벨 플러그인 2021. 9. 3.
[React Native] jdk8 build error 평상시 처럼 안드로이드를 빌드했는데 java 관련 빌드 에러 발생. An exception has occurred in the compiler (1.8.0_265). Please file a bug against the Java compiler via the Java bug reporting page (http://bugreport.java.com) after checking the Bug Database (http://bugs.java.com) for duplicates. Include your program and the following diagnostic in your report. Thank you. java.lang.AssertionError: annotationType(): unrecogni.. 2021. 9. 3.
> Task :react-native-firebase_messaging:compileDebugJavaWithJavac FAILED - build.gradle (app): project.ext.envConfigFiles = [ debug: ".env", releasestaging: ".env.staging", release: ".env.production" ] buildscript { repositories { gradlePluginPortal() } dependencies { classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.12.10, 0.99.99]' } } apply plugin: "com.android.application" apply plugin: 'com.google.gms.google-services' apply plugin: 'com.onesignal.. 2021. 9. 3.