`How to work with destructuring when declaring in typescript?
Z
Z
zwezew2019-04-08 17:10:59
typescript
zwezew, 2019-04-08 17:10:59

How to work with destructuring when declaring in typescript?

For example, in

interface Props {
    theme? : object;    
}

export const Block = styled.div`
    border: ${({mainTheme}: Props) => `${mainTheme.border} ${mainTheme.color}`};
`;

how to deal with mainTheme.border and mainTheme.color?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Yarkov, 2019-04-08
@zwezew

It?

interface Props {
    theme: Theme;
}

interface Theme {
    border: string;
    color: string;
}

export const Block = `
    border: ${({theme: mainTheme}: Props) => `${mainTheme.border} ${mainTheme.color}`};
`;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question