Just-in-Time Learning initiative

Version 1.2

These instructions are a condensed version of a screencast on how to build JSX components from JSON.

Unlike the screencast, this script also shows how to simulate this in an Expo Snack. Jump to instructions for snack.

1. Records from data using Expo command line

You should only need to make changes to App.js, not Card.js. The technique is slightly different for a Snack, as indicated in section 2 at bottom.

Make sure your JSON is correct

Add hooks for loading and updating data

Replace the explicit list with a function to generate it

Define this record-generating function

🐞 Problem: infinite loop

🐞 Problem: missing keys

🐞 Problem: can't update action

🐞 Problem: old, class-based syntax

2. Records from data using Snack

Because Snacks are Web based, trying to fetch an external file without special headers can generate a CORS (Cross-Origin Resource Sharing) error. You can still simulate loading JSON by the following technique.

Make sure your JSON is correct

Add your JSON as a file in your Snack

Replace the explicit list with a function to generate it

Define this record-generating function

Import your JSON

Now your cards should show up with the individualized content from your JSON. 🏁