Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to produce types for Containers? #91

Open
colthreepv opened this issue Nov 5, 2020 · 0 comments
Open

How to produce types for Containers? #91

colthreepv opened this issue Nov 5, 2020 · 0 comments

Comments

@colthreepv
Copy link

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> ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant