import { Text, View, Image, Pressable } from 'react-native'; import { gStyle } from…
- User
import { Text, View, Image, Pressable } from 'react-native'; import { gStyle } from '../styles/style'; import React, {useState, useEffect} from 'react'; import { useNavigation } from '@react-navigation/native'; import {firebase} from '../Firebase/firebase'; import moment from 'moment'; import 'firebase/compat/storage'; import 'firebase/compat/firestore';
export default function FutureMK() { const navigation = useNavigation(); const [futureMKData, setFutureMKData] = useState([]);
useEffect(() => { const fetchData = async () => { try { const futureMKRef = firebase.firestore().collection('FutureMK'); const snapshot = await futureMKRef.get(); const data = snapshot.docs.map((doc) => doc.data()); const storage=firebase.storage(); const updateData = await Promise.all(data.map(async(mkData)=>{ const imagePath = mkData.imageUrl; const imageRef = storage.ref().child(imagePath); const url = await imageRef.getDownloadURL(); return {...mkData, imageUrl:url}; })) setFutureMKData(updateData); } catch (error) { console.log(error); } }; fetchData(); }, []);return ( {futureMKData.map((mkData, index)=>( {moment(mkData.time.toDate()).format('Do MMM YYYY')} {mkData.name} Цена: {mkData.price} P. {mkData.description && mkData.description.length>100 ? mkData.description.substring(0,100)+'...' : mkData.description || ''} <Pressable style={gStyle.FutureMKmoreDetails} onPress={()=>{navigation.navigate('SignUpForMK',{mkData});}} > Подробнее ))}
</View>); }
LOG [TypeError: Cannot read property 'split' of undefined] i cant see data from db where i want, yesterday it worked but now it doesnt show anything and i didnt do anything
- Assistant
to the code. The error message is related to a null or undefined value being used with the "split" method, so it might be related to the way you're accessing the data from the database. Double-check that all the necessary fields are present and properly formatted in your database, and try refreshing your database connection and/or clearing your cache to see if that resolves the issue. If the problem persists, consider updating your post with more information about the specific error message and any relevant code snippets to help others troubleshoot the issue.
- User
how to clear cash
- Assistant
In order to clear the cache in React Native, you can try the following steps:
-
Stop the metro bundler by pressing
CTRL + Cin the terminal where the bundler is running. -
Delete the
node_modulesfolder in your project directory by running therm -rf node_modulescommand in the terminal. -
Delete the
package-lock.jsonfile in your project directory. -
Clear the cache in your project by running one of the following commands in the terminal:
npm cache cleanyarn cache clean
-
Reinstall the node modules by running
npm installoryarnin the terminal. -
Restart the metro bundler by running
npm startoryarn startin the terminal.
This should clear the cache in your project and refresh any cached data, including data from your Firebase database.
-
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.