묻고 답해요
132만명의 커뮤니티!! 함께 토론해봐요.
인프런 TOP Writers
-
미해결처음 배우는 리액트 네이티브
ReferenceError: Can't find variable: Data
import React, { useState } from 'react'; import { StatusBar, Dimensions } from 'react-native'; import styled, {ThemeProvider} from 'styled-components/native'; import {theme} from './theme'; import Input from './components/Input'; import Task from './components/Task'; const Container = styled.SafeAreaView` flex: 1; background-color: ${({theme}) => theme.background}; align-items: center; justify-content: flex-start; /* 타이틀이 상단에 나타나도록 justify-content의 값을 flex-start;로 지정해준다. */ `; const Title = styled.Text` font-size: 40px; font-weight: 600; color: ${({theme}) => theme.main}; width: 100%; align-items: flex-end; padding: 0 20px; `; /* styled components를 이용해서 Title이라는 이름에 새로운 컴포넌트를 만드는 작업이다. font-size와 font-weight 그리고 글자 color를 설정해주는데 글자 color는 theme.js에 정의해놓은 main을 가져와서 사용할것이다. 가로(width)는 전체를 차지하게하고, 글자를 왼쪽(align-items: flex-end;)에서부터 하도록한다. 화면의 끝에 바짝붙지않도록 padding을 주어서 약간 떨어지게 설정을한다. */ const List = styled.ScrollView` flex: 1; width: ${({ width }) => width -40}px; `; export default function App() { const width = Dimensions.get('window').width; const tempData = { 1: { id: '1', text: 'React Native', completed: false }, 2: { id: '2', text: 'Expo', completed: true }, 3: { id: '3', text: 'JavaScript', completed: false }, }; const [tasks, setTasks] = useState(tempData); const [newTask, setNewTask] = useState(''); const addTask = () => { const ID = Data.now().toString(); const newTaskObject ={ [ID] : {id: ID, text: newTask, completed: false }, }; setNewTask(''); setTasks({...tasks, ...newTaskObject}); }; return ( <ThemeProvider theme={theme}> <Container> <StatusBar style="light-content" backgroundColor={theme.background} /> <Title>TODO List</Title> <Input placeholder="+ Add a Task" value={newTask} onChangeText = {text => setNewTask(text)} onSubmitEditing={addTask} /> <List width = {width}> {Object.values(tasks) .reverse() .map(item => ( <Task key={item. id} text={item.text} /> ))} </List> </Container> </ThemeProvider> ); } 강의에 나오는것과 똑같이 했는데 +Add a Task에 글자입력하고 enter를 누르면 오류가 나오네요ㅠㅠ
-
미해결처음 배우는 리액트 네이티브
안드로이드 변수 오류
1. github 주소: https://github.com/Gophycal/Inflearn 2. 오류사항 ReferenceError: Can't find variable: IDBIndex - ... 9 more stack frames from framework internals Invariant Violation: "main" has not been registered. This can happen if: * Metro (the local dev server) is run from the wrong folder. Check if Metro is running, stop it and restart it in the current project. * A module failed to load due to an error and `AppRegistry.registerComponent` wasn't called. at node_modules/react-native/Libraries/Core/ExceptionsManager.js:104:6 in reportException at node_modules/react-native/Libraries/Core/ExceptionsManager.js:172:19 in handleException at node_modules/react-native/Libraries/Core/setUpErrorHandling.js:24:6 in handleError at node_modules/@react-native/polyfills/error-guard.js:49:36 in ErrorUtils.reportFatalError 3. package.json { "main": "node_modules/expo/AppEntry.js", "scripts": { "start": "expo start", "android": "expo start --android", "ios": "expo start --ios", "web": "expo start --web", "eject": "expo eject" }, "dependencies": { "@react-native-community/masked-view": "^0.1.11", "@react-navigation/bottom-tabs": "^6.0.9", "@react-navigation/native": "^6.0.6", "@react-navigation/stack": "^6.0.11", "expo": "^43.0.0", "expo-image-picker": "~11.0.3", "expo-status-bar": "~1.1.0", "firebase": "^9.6.1", "moment": "^2.29.1", "prop-types": "^15.7.2", "react": "17.0.1", "react-dom": "17.0.1", "react-native": "0.64.3", "react-native-gesture-handler": "~1.10.2", "react-native-gifted-chat": "^0.16.3", "react-native-keyboard-aware-scroll-view": "^0.9.5", "react-native-reanimated": "~2.2.0", "react-native-safe-area-context": "3.3.2", "react-native-screens": "~3.8.0", "react-native-web": "0.17.1", "styled-components": "^5.3.3" }, "devDependencies": { "@babel/core": "^7.12.9" }, "private": true } 4. 문제 발생 지점: 안드로이드 애뮬레이터(Pixel_4) 5. 오류 내용 프로필 화면을 만들던 중 일어난 오류입니다. 구체적으로 navigations의 index, 그리고 firebase.js, screens의 Profile을 수정하여, 'Profile' 스크린에서 사용자의 정보에 따라 이름, 이메일, 사진 등을 보여주는 기능을 추가하는 중에 일어난 오류입니다. 지금 한 5시간째 찾아보고 있는데, 어떻게 해결하는지 잘 모르겠습니다. 추측으로는 노드 모듈에서 버젼이 안 맞는 게 있는 것 같은데, yarn이라든지, npm이라든지 노드 모듈 다 지우고 다시 install 하거나 add 했는데, 오류가 사라지지 않네요. IOS 애뮬레이터(iPhone 13)에서는 오류가 없는데 이상합니다.