Skip to content

Commit fb5cd12

Browse files
committed
#5700 choosing the right base class
1 parent 6bd2fec commit fb5cd12

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

learn/guides/CustomComponents.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,22 @@ solution.
1111

1212
This guide will walk you through the process.
1313

14+
## Choosing the Right Base Class
15+
16+
In the world of React, developers often use Higher-Order Components (HOCs) to reuse component logic. In Neo.mjs, you
17+
achieve a similar result through class extension. The key to creating a robust and efficient custom component is
18+
choosing the correct base class to extend.
19+
20+
Instead of extending the most generic `Neo.component.Base` class, look for a more specialized class that already
21+
provides the functionality you need.
22+
23+
- If your component needs to contain other components, extend `Neo.container.Base`.
24+
- If you're creating an interactive element, extending `Neo.button.Base` gives you focus and keyboard support.
25+
- If you need a custom form field, look for a suitable class within `Neo.form.field`.
26+
27+
By choosing the most specific base class, you inherit a rich set of features, saving you from having to reinvent the
28+
wheel and ensuring your component integrates smoothly into the framework.
29+
1430
## Overriding Ancestor Configs
1531

1632
The simplest way to create a custom component is to extend an existing one and override some of its default

0 commit comments

Comments
 (0)