From the course: The DOM in JavaScript, jQuery, AngularJS, and React

Unlock the full course today

Join today to access over 25,000 courses taught by industry experts.

Encapsulating code in components

Encapsulating code in components

- [Instructor] ReactJS components are just reusable chunks of JavaScript that output HTML elements, and we have this new syntax extension to Javascript syntax called JSX. Components are made up of elements, so virtually every element created in React is a component, and components are mainly the reason why React was created for in the first place. They are created for defining the regional components and interactions that make up what users see in the view when they use your app. So let's take an example and we'll see how that's done. This is the page that has a counter for Frankie and Don. I'm going to turn them off and remove the counters so we can do this example here. So on the HTML page, and we'll scroll down to Don and Frankie, right about line 76 here, so I remove line 80, I don't need that anymore. So I remove line 86 from Don's ID. Okay, so if you look at this information here, you see the information for Frankie, Don, Nick, and so they all look very identical, right, they…

Contents