Libraries in React
A brief introduction to React APIs and their uses.
React is only the view layer for your application. There is some internal state management offered by React, but apart from this, it is only a component library which renders HTML for your browser. Everything else can be added from APIs (e.g. browser API, DOM API), JavaScript functionalities or external libraries. It’s not always simple to choose the right library for complementing your React application, but once you have a good overview of the different options, you can pick the one which fits best to your tech stack.
For instance, fetching data in React can be done with the native fetch API like so. Lines 2 and 3 define constant variables that return a JSON based on a query from a website (API). Lines 15-17 in the componentDidMount()
method (this will be discussed in future lessons) fetch the data and set the title within the state to a title returned in the JSON file from the API given here.
Get hands-on with 1200+ tech skills courses.