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

Exported types #103

Open
ferrybrouwer opened this issue Dec 10, 2021 · 0 comments
Open

Exported types #103

ferrybrouwer opened this issue Dec 10, 2021 · 0 comments

Comments

@ferrybrouwer
Copy link

ferrybrouwer commented Dec 10, 2021

Would be nice to have exported types for outer props.

Consider the following implementation:

import { useContainerQuery } from 'react-container-query';
import classnames from 'classnames';

const query = {
  foo: { minWidth: 320 }
};

const App = () => {
   const [classes, ref] = useContainerQuery(query, {});

  return <div ref={ref} className={classnames(classes)}>...</div>
};

It would be handy to know the type of query without having to infer from value.

Current workaround solution:

type Query = Parameters<typeof useContainerQuery>[0];

besides this is ugly to declare it this way, it's also dangerously to always assume it will be the first parameter (future proof wise).

Suggested solution:

import type { Query } from 'react-container-query';
import { useContainerQuery } from 'react-container-query';

const queries:Query = {
  foo: { minWidth: 320 }
};

const App = () => {
   const [classes, ref] = useContainerQuery(queries, {});

  return <div ref={ref} className={classnames(classes)}>...</div>
};
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