Summary
In this chapter, we introduced JavaScript frameworks and described how they work with Django to enhance templates and add interactivity. We introduced the JavaScript language and covered some of its main features, variable types, and classes. We then introduced the concepts behind React and how it builds HTML by using components. We built a React component using just JavaScript and the React.createElement
function. After that, we introduced JSX and saw how it made the development of components easier by letting you directly write HTML in your React components. The concepts of promises
and the fetch
function were introduced, and we saw how to get data from a REST API using fetch
. The chapter finished with an exercise that retrieved reviews from Bookr using the REST API and rendered them to the page in an interactive component.
In the next chapter, we will look at how to deploy our Django project to a production web server.