@@ -17,6 +17,7 @@ import Course from "../components/Course";
1717import Menu from "../components/Menu" ;
1818import Avatar from "../components/Avatar" ;
1919import CardsQuery from "../components/CardsQuery" ;
20+ import CoursesQuery from "../components/CoursesQuery" ;
2021
2122function mapDispatchToProps ( dispatch ) {
2223 return {
@@ -148,9 +149,20 @@ class HomeScreen extends React.Component {
148149 </ CardsQuery >
149150 </ ScrollView >
150151 < Subtitle > Popular Courses</ Subtitle >
151- { courses . map ( course => (
152- < Course { ...course } key = { course . title } />
153- ) ) }
152+ < CoursesQuery >
153+ { ( { loading, error, data } ) => {
154+ if ( loading ) {
155+ return < Message > Loading...</ Message > ;
156+ }
157+ if ( error ) {
158+ return < Message > Error...</ Message > ;
159+ }
160+ const { courses } = data ;
161+ return courses . map ( course => (
162+ < Course { ...course } key = { course . id } />
163+ ) ) ;
164+ } }
165+ </ CoursesQuery >
154166 </ ScrollView >
155167 </ SafeAreaView >
156168 </ AnimatedContainer >
@@ -237,43 +249,3 @@ const logos = [
237249 text : "Sketch"
238250 }
239251] ;
240-
241- const courses = [
242- {
243- title : "Prototype in InVision Studio" ,
244- subtitle : "10 sections" ,
245- image : require ( "../assets/background13.jpg" ) ,
246- logo : require ( "../assets/logo-studio.png" ) ,
247- author : "Meng To" ,
248- avatar : require ( "../assets/avatar.jpg" ) ,
249- caption : "Design an interactive prototype"
250- } ,
251- {
252- title : "React for Designers" ,
253- subtitle : "12 sections" ,
254- image : require ( "../assets/background11.jpg" ) ,
255- logo : require ( "../assets/logo-react.png" ) ,
256- author : "Meng To" ,
257- avatar : require ( "../assets/avatar.jpg" ) ,
258- caption : "Learn to design and code a React site"
259- } ,
260- {
261- title : "Design and Code with Framer X" ,
262- subtitle : "10 sections" ,
263- image : require ( "../assets/background14.jpg" ) ,
264- logo : require ( "../assets/logo-framerx.png" ) ,
265- author : "Meng To" ,
266- avatar : require ( "../assets/avatar.jpg" ) ,
267- caption : "Create powerful design and code components for your app"
268- } ,
269- {
270- title : "Design System in Figma" ,
271- subtitle : "10 sections" ,
272- image : require ( "../assets/background6.jpg" ) ,
273- logo : require ( "../assets/logo-figma.png" ) ,
274- author : "Meng To" ,
275- avatar : require ( "../assets/avatar.jpg" ) ,
276- caption :
277- "Complete guide to designing a site using a collaborative design tool"
278- }
279- ] ;
0 commit comments