I am trying to follow a youtube video on developing a kanban board in react-native, the video tutorial is for react and I am very new to react and react-native or even javascript in general.
App.tsx :
import React, {useState, useRef} from 'react';
import {Text, SafeAreaView, Image, Animated, View, Button, StyleSheet,Pressable,TextInput,TouchableOpacity} from 'react-native';
import {DragDropContext, Droppable, Draggable} from 'react-beautiful-dnd';
//import uuid from 'react-native-uuid';
const itemsFromBackend = [
{id: "1", content: 'Task1'},
{id: "2", content: 'Task2'}
];
const columnsFromBackend = [
{
'Todo':{
name : 'Todo',
items : itemsFromBackend
}
}
];
const Kanban = () => {
const [columns, setColumns] = useState(columnsFromBackend)
return(
<SafeAreaView style = {styles.container} >
<SafeAreaView style= {styles.header_img}>
<Image style= {styles.images} source = {require('./assets/Kanban-board-1.png')}></Image>
</SafeAreaView>
<SafeAreaView style={styles.header}>
<Image style= {styles.images} source = {require('./assets/to_do.png')}></Image>
</SafeAreaView>
<SafeAreaView style={{flex:1}}>
<Text>CONTENT 1</Text>
<DragDropContext onDragEnd={result=> console.log(result)}>
{Object.entries(columns).map(([id, column]) => {
return(
<Droppable droppableId={id}>
{(provided, snapshot) => {
return(
<div {...provided.droppableProps} ref={provided.innerRef} style={{
backgroundColor: snapshot.isDraggingOver ? 'lightblue' : 'lightgrey',
padding: 4,
width: 250,
minHeight: 500
}}>
{column.Todo.items.map((item, index) => {
return(
<Draggable key={item.id} draggableId={item.id} index={index}>
{(provided,snapshot) => {
return(
<div {...provided.draggableProps} {...provided.innerRef} {...provided.draggableProps} style={{
userSelect: 'none',
padding: 16,
margin: '0 0 8px 0',
minHeight: '50px',
backgroundColor: snapshot.isDragging ? 'yellow' : 'orange',
color: 'black',
...provided.draggableProps.style
}}>
{item.content}
</div>
);
}}
</Draggable>
);
})}
</div>
)
}}
</Droppable>
);
}
)
}
</DragDropContext>
</SafeAreaView>
</SafeAreaView>
);
};
{/* ===================== STYLING COMPONENTS =====================*/}
const styles = StyleSheet.create({
container : {flex:1,
borderWidth:5
},
images: {height:100,
resizeMode:"contain",
width:300
},
header : {
flex:1,
justifyContent:"center",
alignItems:"center",
borderWidth:1,
margin:1,
padding: 1
},
header_img : {flex:2,
justifyContent:"center",
alignItems:"center",
borderWidth:1,
margin:1,
padding: 1
},
threebox : {flex:4,
flexDirection:"row",
borderWidth:1}
});
export default Kanban;
The following errors are popping up in the error logs of the server when I do ‘expo start’ from the expo-cli and render the app using my phone or browser:-
Error
15:30
Warning: Each child in a list should have a unique "key" prop.
Check the render method of `Kanban`. See https://reactjs.org/link/warning-keys for more information.
Connect(Droppable)@http://2y-38e.amalmajeed.kanban-notes.exp.direct/node_modules/expo/AppEntry.bundle?platform=ios&dev=true&hot=false&strict=false&minify=false:127744:43
in Kanban (created by ExpoRoot)
in ExpoRoot
in RCTView (created by View)
in View (created by AppContainer)
in DevAppContainer (created by AppContainer)
in RCTView (created by View)
in View (created by AppContainer)
in AppContainer
Stack trace:
node_modules/react-native/Libraries/LogBox/LogBox.js:174:8 in registerError
node_modules/react-native/Libraries/LogBox/LogBox.js:60:8 in errorImpl
node_modules/react-native/Libraries/LogBox/LogBox.js:34:4 in console.error
node_modules/expo/build/environment/react-native-logs.fx.js:27:4 in error
node_modules/react/cjs/react-jsx-runtime.development.js:117:4 in printWarning
node_modules/react/cjs/react-jsx-runtime.development.js:93:16 in error
node_modules/react/cjs/react-jsx-runtime.development.js:986:9 in validateExplicitKey
node_modules/react/cjs/react-jsx-runtime.development.js:1013:29 in validateChildKeys
node_modules/react/cjs/react-jsx-runtime.development.js:1184:27 in jsxWithValidation
App.tsx:43:6 in Kanban
node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:10121:26 in renderWithHooks
node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:13183:27 in mountIndeterminateComponent
node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:19794:22 in beginWork$1
node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:18563:22 in performUnitOfWork
node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:18499:21 in workLoopSync
node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:18464:18 in renderRootSync
node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:18158:31 in performSyncWorkOnRoot
[native code]:null in performSyncWorkOnRoot
node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:5911:33 in runWithPriority$argument_1
node_modules/scheduler/cjs/scheduler.development.js:468:23 in unstable_runWithPriority
node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:5906:23 in flushSyncCallbackQueueImpl
node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:5893:28 in flushSyncCallbackQueue
node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:17745:30 in scheduleUpdateOnFiber
node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:21484:23 in updateContainer
node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:22144:17 in render
node_modules/react-native/Libraries/ReactNative/renderApplication.js:58:4 in renderApplication
node_modules/react-native/Libraries/ReactNative/AppRegistry.js:117:25 in runnables.appKey.run
node_modules/react-native/Libraries/ReactNative/AppRegistry.js:202:4 in runApplication
node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:414:4 in __callFunction
node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:113:6 in __guard$argument_0
node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:365:10 in __guard
node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:112:4 in callFunctionReturnFlushedQueue
[native code]:null in callFunctionReturnFlushedQueue
...
Error
15:30
TypeError: el.addEventListener is not a function. (In 'el.addEventListener(binding.eventName, binding.fn, options)', 'el.addEventListener' is undefined)
This error is located at:
in ErrorBoundary (created by DragDropContext)
in DragDropContext (created by Kanban)
in RCTSafeAreaView
in SafeAreaView (created by Kanban)
in RCTSafeAreaView
in SafeAreaView (created by Kanban)
in Kanban (created by ExpoRoot)
in ExpoRoot
in RCTView (created by View)
in View (created by AppContainer)
in DevAppContainer (created by AppContainer)
in RCTView (created by View)
in View (created by AppContainer)
in AppContainer
Stack trace:
node_modules/react-native/Libraries/LogBox/LogBox.js:149:8 in registerError
node_modules/react-native/Libraries/LogBox/LogBox.js:60:8 in errorImpl
node_modules/react-native/Libraries/LogBox/LogBox.js:34:4 in console.error
node_modules/expo/build/environment/react-native-logs.fx.js:27:4 in error
node_modules/react-native/Libraries/Core/ExceptionsManager.js:104:6 in reportException
node_modules/react-native/Libraries/Core/ExceptionsManager.js:172:19 in handleException
node_modules/react-native/Libraries/Core/ReactFiberErrorDialog.js:43:2 in showErrorDialog
node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:15792:34 in logCapturedError
node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:15884:20 in update.callback
node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:7199:2 in callCallback
node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:7220:20 in commitUpdateQueue
node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:16632:25 in commitLifeCycles
node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:19216:22 in commitLayoutEffects
node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:93:4 in invokeGuardedCallbackProd
node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:318:2 in invokeGuardedCallback
node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:18952:29 in commitRootImpl
[native code]:null in commitRootImpl
node_modules/scheduler/cjs/scheduler.development.js:468:23 in unstable_runWithPriority
node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:18791:17 in commitRoot
node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:18192:12 in performSyncWorkOnRoot
[native code]:null in performSyncWorkOnRoot
node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:5911:33 in runWithPriority$argument_1
node_modules/scheduler/cjs/scheduler.development.js:468:23 in unstable_runWithPriority
node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:5906:23 in flushSyncCallbackQueueImpl
node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:5893:28 in flushSyncCallbackQueue
node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:17745:30 in scheduleUpdateOnFiber
node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:21484:23 in updateContainer
node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:22144:17 in render
node_modules/react-native/Libraries/ReactNative/renderApplication.js:58:4 in renderApplication
node_modules/react-native/Libraries/ReactNative/AppRegistry.js:117:25 in runnables.appKey.run
node_modules/react-native/Libraries/ReactNative/AppRegistry.js:202:4 in runApplication
node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:414:4 in __callFunction
node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:113:6 in __guard$argument_0
node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:365:10 in __guard
node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:112:4 in callFunctionReturnFlushedQueue
[native code]:null in callFunctionReturnFlushedQueue
...
Error
15:30
TypeError: el.addEventListener is not a function. (In 'el.addEventListener(binding.eventName, binding.fn, options)', 'el.addEventListener' is undefined)
This error is located at:
in ErrorBoundary (created by DragDropContext)
in DragDropContext (created by Kanban)
in RCTSafeAreaView
in SafeAreaView (created by Kanban)
in RCTSafeAreaView
in SafeAreaView (created by Kanban)
in Kanban (created by ExpoRoot)
in ExpoRoot
in RCTView (created by View)
in View (created by AppContainer)
in DevAppContainer (created by AppContainer)
in RCTView (created by View)
in View (created by AppContainer)
in AppContainer
Stack trace:
node_modules/react-native/Libraries/LogBox/LogBox.js:149:8 in registerError
node_modules/react-native/Libraries/LogBox/LogBox.js:60:8 in errorImpl
node_modules/react-native/Libraries/LogBox/LogBox.js:34:4 in console.error
node_modules/expo/build/environment/react-native-logs.fx.js:27:4 in error
node_modules/react-native/Libraries/Core/ExceptionsManager.js:104:6 in reportException
node_modules/react-native/Libraries/Core/ExceptionsManager.js:172:19 in handleException
node_modules/react-native/Libraries/Core/setUpErrorHandling.js:24:6 in handleError
node_modules/expo-error-recovery/build/ErrorRecovery.fx.js:12:21 in ErrorUtils.setGlobalHandler$argument_0
node_modules/regenerator-runtime/runtime.js:63:36 in tryCatch
node_modules/regenerator-runtime/runtime.js:294:29 in invoke
node_modules/regenerator-runtime/runtime.js:63:36 in tryCatch
node_modules/regenerator-runtime/runtime.js:155:27 in invoke
node_modules/regenerator-runtime/runtime.js:165:18 in PromiseImpl.resolve.then$argument_0
node_modules/react-native/node_modules/promise/setimmediate/core.js:37:13 in tryCallOne
node_modules/react-native/node_modules/promise/setimmediate/core.js:123:24 in setImmediate$argument_0
node_modules/react-native/Libraries/Core/Timers/JSTimers.js:123:14 in _callTimer
node_modules/react-native/Libraries/Core/Timers/JSTimers.js:177:14 in _callImmediatesPass
node_modules/react-native/Libraries/Core/Timers/JSTimers.js:437:30 in callImmediates
node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:388:6 in __callImmediates
node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:132:6 in __guard$argument_0
node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:365:10 in __guard
node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:131:4 in flushedQueue
[native code]:null in flushedQueue
[native code]:null in invokeCallbackAndReturnFlushedQueue
...
Here is my ‘package.json’ file for the project :
{
"name": "kanban-notes",
"version": "1.0.0",
"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": {
"buffer": "^6.0.3",
"expo": "~44.0.0",
"expo-status-bar": "~1.2.0",
"react": "17.0.1",
"react-beautiful-dnd": "^13.1.0",
"react-dom": "17.0.1",
"react-native": "0.64.3",
"react-native-draganddrop-board": "^1.0.4",
"react-native-uuid": "^2.0.1",
"react-native-web": "0.17.1",
"uuid": "^8.3.2",
"uuidv4": "^6.2.12"
},
"devDependencies": {
"@babel/core": "^7.12.9",
"@types/react": "~17.0.21",
"@types/react-beautiful-dnd": "^13.1.2",
"@types/react-native": "~0.64.12",
"@types/uuid": "^8.3.4",
"typescript": "~4.3.5"
},
"private": true
}
Not sure how to proceed from here, kindly let me know how to get rid of this ?
P.S : I use VS CODE in Mac to run the expo-cli