⚠️ This lesson is retired and might contain outdated information.

Use an AWS Amplify DataStore Backend in a React Application

Ali Spittel
InstructorAli Spittel
Share this video with your friends

Social Share Links

Send Tweet
Published 3 years ago
Updated 2 weeks ago

In this video, we'll test out a schema created in the Amplify Admin UI locally. You will be able to test out your data without an AWS account. We'll first create a React app, then install the necessary dependencies, pull in our Amplify-created backend, and then add create and read functionality to a Course model.

Ali Spittel: [0:00] I'm going to go to my App.js, and I'll clear out what's already in here. I'm going to switch over to course instead of video here. I'm going to add a button.

[0:10] What we can see is that when you click on that button, it triggers an addCourse() function. I'll copy and paste these snippets. First, I'll add this to the top because these are imports that I need. Then, I'll copy this snippet into the addCourse function.

[0:29] I need to make this asynchronous because I'm using an await. Instead of using lorem ipsum text, I'll do a window.prompt. I'll also remove the videos array because our course will not have videos initially. When I go to my localhost:3000, there's a button to add a course. First, I'll enter my course title and add a description.

[0:55] I need to add a function to display my courses on the page. First, I'll import useEffect from React. I'll make it so that there's an asynchronous function inside of useEffect because the callback to useEffect should not be asynchronous.

[1:23] I'll also call this function here. Inside of that, I'm going to switch over to the Query tab here. I've already done these imports, but I'm going to copy and paste this [inaudible] event. When my page loads, I have an array of objects with my React course.

[1:41] One note about this data is that since it's using data store it'll be available offline or online and across user. You don't need to do anything else to have your data available offline.

[1:52] In this video, we've created a React app, we configured it to use AWS Amplify, and we used DataStore to interact with our data.

egghead
egghead
~ 3 minutes ago

Member comments are a way for members to communicate, interact, and ask questions about a lesson.

The instructor or someone from the community might respond to your question Here are a few basic guidelines to commenting on egghead.io

Be on-Topic

Comments are for discussing a lesson. If you're having a general issue with the website functionality, please contact us at support@egghead.io.

Avoid meta-discussion

  • This was great!
  • This was horrible!
  • I didn't like this because it didn't match my skill level.
  • +1 It will likely be deleted as spam.

Code Problems?

Should be accompanied by code! Codesandbox or Stackblitz provide a way to share code and discuss it in context

Details and Context

Vague question? Vague answer. Any details and context you can provide will lure more interesting answers!

Markdown supported.
Become a member to join the discussionEnroll Today