Using access modifiers

In this lesson, we'll learn the different access modifiers that are available on class members and how to implement them.

We'll cover the following

We are going to continue the implementation of the Counter component we worked on in the last lesson.

Click the link below to open the exercise in CodeSandbox:

CodeSandbox project

This is the component we implemented in the last lesson with the button click handler extracted into a method within the class component. There is also a class property called clicked, which tracks how many times the button has been clicked.

Public members

At the bottom of index.tsx add the following statement:

const counter = new Counter({ initialCount: 0 });

On the next line, inspect the members that are available in counter:

Get hands-on with 1000+ tech skills courses.

Learn to code, grow your skills, and succeed in your tech interview