GeekyAnts / NativeBase

Mobile-first, accessible components for React Native & Web to build consistent UI across Android, iOS and Web.
https://nativebase.io/
MIT License
20.2k stars 2.39k forks source link

Export more utility hooks, component hooks, contexts, types, etc.. where possible #5360

Closed akinzalowevidation closed 2 years ago

akinzalowevidation commented 2 years ago

Description

We wrap most of the NativeBase components to add our own functionality and in some cases create our own NativeBase components from scratch. We've had success with this so far, despite some having to have some ugly imports such as:

import type { InterfaceBoxProps } from 'native-base/lib/typescript/components/primitives/Box';
import type { CustomProps } from 'native-base/lib/typescript/components/types';

This works fine for types, but not anything else.

Today we began making our first component from scratch that relied on interaction states. Upon further investigate we discovered that other NB components rely on hooks defined in Pressable (useHover, usePressed, etc..). These hooks do not appear to be exported, making it difficult to build our own components and attempt to follow NB component structure - most notably using usePropsResolution.

Problem Statement

Currently it is not fully possible to create some custom NativeBase-like components by exporting types, hooks, or other components from native-base. For users that create an internal component library that wraps native-base, this is an important requirement to have.

Proposed Solution or API

Export more (or all) types, utility functions (such as mergeRefs), utility hooks, component hooks, component contexts, etc.. out of native-base.

Alternatives

We could fork NativeBase, but our goal is not to add additional features or changes to NativeBase itself, but rather just utilize all existing features NativeBase has to build our own components in the same manner that NativeBase components are built.

It is also much easier in these cases where we are wrapping NativeBase to simply upgrade a NativeBase version over maintaining forked code.

Additional Information

If needed, I can offer some more use case examples.

ankit-tailor commented 2 years ago

Hey @akinzalowevidation, Thanks for your suggestions. We'll need some discussion on this.