Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6287

how to type an array of objects coming from realmDB?

$
0
0

Error: Argument of type 'Results<Courses[] & Object>' is not assignable to parameter of type 'SetStateAction<Courses[]>'.Type 'Results<Courses[] & Object>' does not have the following properties of type 'Courses[]': pop, push, reverse, shift, and more 6.ts(2345)

// my interfaceinterface Courses {  id: string;  name: string;  image: string;}const [courses, setCourses] = useState<Courses[]>([]);useEffect(() => {    async function getOfflineCourses() {      const realmDB = await realm;      realmDB.write(() => {        const offlineCourses = realmDB.objects<Courses[]>('Course');        setCourses(offlineCourses);      });    }    getOfflineCourses();  }, [realm]);

Viewing all articles
Browse latest Browse all 6287

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>