728x90

Development 69

[error] Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up d..

[Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports. ----->> 원인 : 파일이름과 선언한 곳에서의 이름이 일치하지 않으면 발생하는 것 같다 예) Home.js로 작성 사용하려는 곳에서 Import {SweeHome} from ‘./Home.js’ 이렇게 사용하였더니 발생하였..

Development/Error 2024.01.22

[study] mac 환경 세팅 중 만났던 에러 해결

현재 내 상황 컴퓨터 : 맥북 프로 16 -버전 : macOS 14.2.1 xcode : 15 ———————cli 문제 해결 ——————— 프로젝트 설치 전 : npm uninstall -g react-native-cli @react-native-community/cli //cli 삭제 프로젝트 설치 : npx react-native@latest init efenpx //후 최신 버전으로 재설치 react-native doctor // 문제상황 보고서 ———————Pod dependency 문제 해결——————— After upgrading to latest version of gems and cocoa pods. can run any pod commands * sudo gem uninstall acti..

[study] 240122

작은 단위 컴포넌트부터 만들기 Atomic design pattern : 작은단위부터 큰 단위까지 컴포넌트를 조합해 만들어가는 것 (Lego 조립과 비슷) React-natived에서 자주 사용하는 hook -useWindowDimensions // 디바이스별로 화면 크기를 조절할 수 있다. export const ComponentA = (props) => { const {window, height}=useWindowDimensions(); {…etc code} } -useBackHandler npm install @react-native-community/hooks -useAppState npm install @react-native-community/hooks -useNavigation, useRou..

[study] 중복함수실행방지

커뮤니티 기능 구현 중 글쓰기 버튼을 두 번 누르니, 글쓰기 함수가 두 번 실행되어 글이 중복 작성되는 오류를 발견하였다. 구글링 결과 해결방법은 1. state를 만들어 버튼 disabled 속성에 적용한다. 2. 버튼을 눌렀을 때 state값이 true로 변하게 하여 버튼이 눌리지 않게 한다. 3. 혹시나 눌렀을 경우를 대비해 버튼을 눌렀을 때 실행되는 함수에서도 실행되었을 때 state값이 true로 변하게 하여 버튼이 눌리지 않게 한다. //그러면 2번에서 혹시나 중복으로 누르게 되었어도 첫 번째 함수가 실행되었을 때 state값이 true 가 되므로 함수가 두 번 실행되지 않는다. 함수가 끝났을 때는 다시 state가 false로 바뀐다.(state의 기본값) 예) 1. state 값 설정 #..

[study] swiper

swiper가 적용이 안되어서, swipeable을 써보기도 하고, 별의별 방법을 며칠 동안 다 시도해 보았다. 결국 버튼을 이용해 개발 업데이트를 진행했는데, 역시나 계속 시도해 보고, 알아보니 해결되었다. 생각보다 간단해 허무하기도 했다. 해결 : swiper를 presseble이 감싸고 있었기 때문에 적용이 안되었던 것. 예) ... TouchableOpacity로 감싸도 마찬가지였다. 페이지에 컴포넌트가 두 개인 상황이었고, 아래 컴포넌트를 이용 중 위 컴포넌트를 눌렀을 때 아래 컴포넌트의 내용이 reset 될 수 있게 하려고 swiper가 있는 위 컴포넌트를 presseble로 감싸 onPress속성으로 setState를 적용하고 있었다. 예) setState(! state)}> ... *st..

[study] .map : array안에 object 형태로 추가하기 - 240111

@ map - array에 object 넣기 문제 : const [images, setImages] = useState([]); const images = res.assets.map( item => { const image= { name:item.fileName, type:item.type, uri:item.uri } return image }) setImages([image]) // images가 빈 배열이라 바로 setImages에 담았고, 하나의 array가 되었다. 다만, 기존에 있는 배열에 image를 추가하고 싶은 경우라면 const images = res.assets.map( item => { const image= { name:item.fileName, type:item.type, uri:..

728x90