Skip to main content

Naming Conventions

Libraries should be developed in accordance with naming conventions to ensure consistency.

Mixin Function Names​

Mixin function names follow a format like with[Feature], rather than the use[Hook] format used in React.

Example: withQuery, withForm, withA11y, etc.

By using this naming convention, users will be able to write code in an intuitive way, as shown below:

class MyComponent extends withQuery(Component) {
// ...
}

Mixin Type Names​

When defining the types of properties or functions injected by a mixin, append “Mixin” to the end, as in [Feature]Mixin.

Example: interface QueryMixin, etc.

It is used to enable code completion in the editor and detect compilation errors, ensuring that the code runs in a type-safe manner.

The following is an example of this pattern in the Query Library:

export interface WithQueryMixin {
createQuery<TData>(queryKey: string, queryFn: () => Promise<TData>, options?: GeaQueryOptions): GeaQuery<TData>;
dispose(...args: any[]): void;
}