encapsulation

Keeping a component's internal data and details behind a small public interface.

In more detail

Callers use the component's methods, props or functions instead of reaching into its internals. That lets the internals change without breaking the code that uses them. Languages enforce it to different degrees, from strict private members to naming conventions.

Example

A React component that exposes a curated imperative handle instead of its DOM node, or a custom hook that returns named actions, is encapsulated.

Related terms

Taught in

References

Certification courses