import { Linking } from 'react-native'; import type { StoreApi, UseBoundStore } from 'zustand'; export function openLinkInBrowser(url: string) { Linking.canOpenURL(url).then((canOpen) => canOpen && Linking.openURL(url)); } type WithSelectors = S extends { getState: () => infer T } ? S & { use: { [K in keyof T]: () => T[K] } } : never; export const createSelectors = >>( _store: S ) => { let store = _store as WithSelectors; store.use = {}; for (let k of Object.keys(store.getState())) { (store.use as any)[k] = () => store((s) => s[k as keyof typeof s]); } return store; };