Skip to content

Exported types #103

@ferrybrouwer

Description

@ferrybrouwer

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>
};

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions