-
-
Notifications
You must be signed in to change notification settings - Fork 408
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error when dragging items: TypeError: Cannot assign to read-only property 'validated' #519
Comments
did you find a solution to this? I have the same error...only started when I upgraded to Expo SDK49 |
Same issue also after upgrading to expo 49. I think it's related to software-mansion/react-native-reanimated#4942. |
Same issue in expo 49. |
I got it to work by making the ListHeaderComponent and Footer instantiated arrow functions, to stop them from being rendered. It worked for my usecase |
This worked for my use case as well |
This works, but causes other problems with my use case (the header has a search bar, and when using a function like this the search text keeps getting cleared when re-rendering). Hoping for another solution. |
So I came up with a workaround. Create a component for your header or footer and pass it into the ListHeaderComponent props like so
To pass in props, you will have to wrap your DraggableFlatlist in a context and access props through useContext. So far, I haven't gotten the error and am able to fill in forms without interruption. There is a solution in the link mentioned by @MPBogdan and the problem is caused by |
The fix can be found here in PR 484 |
Thanks, worked for me... can anyone explain why this works? Before:
After:
|
Describe the bug
So I have 2 issues with react-native-draggable-flatlist, one is that if I use <></> in my ListHeaderComponent (or ListFooterComponenet), I am unable to drag images without getting the error message: ERROR TypeError: Cannot assign to read-only property 'validated'. But changing both to () => solves the issue but brings up another issue that I can't type more than one letter at a time in TextInput, though there are no error messages. I believe the second issue is due to rerendering every time the state of something inside draggable flatlist changes. Interestingly, when I try to change the state of other things in the draggable flatlist (orientation or bio) or add and remove images, I am able to now rearrange the images as per normal. In my code you will see many ways I've tried to fix this bug, all of which unsuccessful.
Platform & Dependencies
package.json:
{ "name": "test", "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" }, "dependencies": { "@firebase/firestore": "^4.4.0", "@react-native-async-storage/async-storage": "1.18.2", "@react-native-community/datetimepicker": "7.2.0", "@react-navigation/bottom-tabs": "^6.5.11", "@react-navigation/drawer": "^6.6.6", "@react-navigation/native": "^6.1.9", "@react-navigation/native-stack": "^6.9.17", "@react-navigation/stack": "^6.3.20", "@reduxjs/toolkit": "^1.9.7", "date-fns": "^2.30.0", "dotenv": "^16.3.1", "expo": "^49.0.21", "expo-av": "~13.4.1", "expo-constants": "~14.4.2", "expo-dev-client": "~2.4.12", "expo-font": "~11.4.0", "expo-image-manipulator": "~11.3.0", "expo-image-picker": "~14.3.2", "expo-router": "^2.0.4", "expo-status-bar": "~1.6.0", "firebase": "^10.6.0", "react": "18.2.0", "react-native": "0.72.6", "react-native-dotenv": "^3.4.9", "react-native-draggable-flatlist": "^4.0.1", "react-native-elements": "^3.4.3", "react-native-fast-image": "^8.6.3", "react-native-gesture-handler": "~2.12.0", "react-native-gifted-chat": "^2.4.0", "react-native-google-places-autocomplete": "^2.5.6", "react-native-maps": "1.7.1", "react-native-reanimated": "~3.3.0", "react-native-select-dropdown": "^3.4.0", "react-native-svg": "13.9.0", "react-native-swiper": "^1.6.0", "react-native-vector-icons": "^10.0.2", "react-redux": "^8.1.3", "redux": "^4.2.1", "redux-thunk": "^2.4.2", "typescript": "^5.1.3", "yarn": "^1.22.19" }, "devDependencies": { "@babel/core": "^7.20.0" }, "android": { "package": "com.test.test" }, "private": true }
Screen that is causing the issues:
`import React, { useEffect, useState, useCallback, useRef } from 'react';
import { View, ScrollView, SafeAreaView, StyleSheet, Text, TouchableOpacity, Alert, TextInput, Image, Button, Dimensions, BackHandler, ActivityIndicator } from 'react-native';
import { useFocusEffect, CommonActions } from '@react-navigation/native';
import { GestureHandlerRootView } from 'react-native-gesture-handler';
import { useDispatch } from 'react-redux';
import { getDoc, updateDoc, doc, setDoc, addDoc, collection, onSnapshot, arrayUnion } from 'firebase/firestore';
import { db, storage } from '../firebase/firebase';
import { getAuth } from 'firebase/auth';
import { uploadBytesResumable, ref, getDownloadURL, deleteObject } from 'firebase/storage';
import DraggableFlatList from 'react-native-draggable-flatlist';
import * as ImagePicker from 'expo-image-picker';
import SelectDropdown from 'react-native-select-dropdown';
import DateTimePicker from '@react-native-community/datetimepicker';
import { setHasUnsavedChangesExport } from '../redux/actions';
import OptionButton from '../components/touchableHighlight/touchableHightlight';
import { COLORS, SIZES, FONT } from '../constants';
import { useAnimatedStyle } from 'react-native-reanimated';
export default function EditProfileScreen({ navigation }) {
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: 'white',
alignItems: 'center',
justifyContent: 'center',
},
btnContainer: {
width: 200,
height: 60,
backgroundColor: COLORS.themeColor,
borderRadius: SIZES.large / 1.25,
borderWidth: 1.5,
borderColor: COLORS.white,
justifyContent: "center",
alignItems: "center",
},
textStyle: {
fontFamily: FONT.medium,
fontSize: SIZES.smallmedium,
color: COLORS.white,
},
textStyle2: {
fontFamily: FONT.medium,
fontSize: SIZES.smallmedium,
color: 'black',
},
});`
Additional context
Call Stack:
ERROR TypeError: Cannot assign to read-only property 'validated'
This error is located at:
in VirtualizedList (created by FlatList)
in FlatList
in Unknown (created by AnimatedComponent(Component))
in AnimatedComponent(Component)
in Unknown (created by DraggableFlatListInner)
in RCTView (created by View)
in View (created by AnimatedComponent(View))
in AnimatedComponent(View)
in Unknown (created by DraggableFlatListInner)
in Wrap (created by AnimatedComponent(Wrap))
in AnimatedComponent(Wrap)
in Unknown (created by GestureDetector)
in GestureDetector (created by DraggableFlatListInner)
in DraggableFlatListProvider (created by DraggableFlatListInner)
in DraggableFlatListInner
in RefProvider
in AnimatedValueProvider
in PropsProvider
in DraggableFlatList (created by EditProfileScreen)
in RCTView (created by View)
in View (created by EditProfileScreen)
in RNGestureHandlerRootView (created by GestureHandlerRootView)
in GestureHandlerRootView (created by EditProfileScreen)
in EditProfileScreen (created by SceneView)
in StaticContainer
in EnsureSingleNavigator (created by SceneView)
in SceneView (created by Drawer)
in RCTView (created by View)
in View (created by Screen)
in RCTView (created by View)
in View (created by Background)
in Background (created by Screen)
in Screen (created by Drawer)
in RNSScreen
in Unknown (created by InnerScreen)
in Suspender (created by Freeze)
in Suspense (created by Freeze)
in Freeze (created by DelayedFreeze)
in DelayedFreeze (created by InnerScreen)
in InnerScreen (created by Screen)
in Screen (created by MaybeScreen)
in MaybeScreen (created by Drawer)
in RNSScreenContainer (created by ScreenContainer)
in ScreenContainer (created by MaybeScreenContainer)
in MaybeScreenContainer (created by Drawer)
in RCTView (created by View)
in View (created by Drawer)
in RCTView (created by View)
in View (created by AnimatedComponent(View))
in AnimatedComponent(View)
in Unknown (created by Drawer)
in RCTView (created by View)
in View (created by AnimatedComponent(View))
in AnimatedComponent(View)
in Unknown (created by PanGestureHandler)
in PanGestureHandler (created by Drawer)
in Drawer (created by DrawerViewBase)
in DrawerViewBase (created by DrawerView)
in RNGestureHandlerRootView (created by GestureHandlerRootView)
in GestureHandlerRootView (created by DrawerView)
in RNCSafeAreaProvider (created by SafeAreaProvider)
in SafeAreaProvider (created by SafeAreaInsetsContext)
in SafeAreaProviderCompat (created by DrawerView)
in DrawerView (created by DrawerNavigator)
in PreventRemoveProvider (created by NavigationContent)
in NavigationContent
in Unknown (created by DrawerNavigator)
in DrawerNavigator (created by DrawerStack)
in EnsureSingleNavigator
in BaseNavigationContainer
in ThemeProvider
in NavigationContainerInner (created by DrawerStack)
in DrawerStack (created by RootNavigation)
in RootNavigation (created by App)
in ThemeProvider (created by App)
in Provider (created by App)
in App (created by withDevTools(App))
in withDevTools(App)
in RCTView (created by View)
in View (created by AppContainer)
in RCTView (created by View)
in View (created by AppContainer)
in AppContainer
in main(RootComponent), js engine: hermes
<></> means:
ListHeaderComponent={
<>
...
</>
}
() => means:
ListHeaderComponent={() =>
...
}
The text was updated successfully, but these errors were encountered: