H
H
hamster1410952021-10-16 06:35:24
typescript
hamster141095, 2021-10-16 06:35:24

How to describe reduce and css styled-component types?

Can't describe types in this function which is used to apply css properties in media-query

import React from 'react';
import styled, { css } from 'styled-components';

const size: MediaQueryProps = {
  small: 400,
  med: 960,
  large: 1140,
};

const above = Object.keys(size).reduce((acc, cur) => {
  acc[cur] = (...args:any) => css`
    @media (min-width: ${size[cur]}px) {
      
      ${css(...args)}
    }
  `;

  return acc;
}, {} as any);

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question