Search⌘ K
AI Features

Using access modifiers

Explore how to use access modifiers to manage the visibility of class properties and methods in React components with TypeScript. Understand public, private, and protected keywords, and how TypeScript enforces access rules during development to create more robust, maintainable code.

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 ...