Skip to content

How to produce types for Containers? #91

Open
@colthreepv

Description

@colthreepv

In certain cases I want to extract functions leveraging containers away from component files, for example

import { longFunction } from './state-helpers'

const Builder: React.FC = () => {
  const app = AppContainer.useContainer()
  const complicatedValue = useMemo(() => longFunction(app), [app])
  return (...)
}

for now I have used on my state.ts something like this:

export const AppContainer = createContainer(useApp)
export type AppContainerState = ReturnType<typeof useApp>

and on my state-helpers.ts my function would be like:

export const longFunction = (app: AppContainerState) => app

The question is, there is anything more elegant than ReturnType<typeof useApp> ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions