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
new hook API #1295
Comments
We believe that for this very reason (among other reasons as well) Refactoring your example to css prop would like this: /** @jsx jsx */
import { jsx, css } from '@emotion/core'
import { useTheme } from 'emotion-theming'
interface FooProps {
title: string;
description: string;
bold: boolean;
}
function Foo(props: FooProps) {
const { title, bold, description } = props;
const theme = useTheme();
const wrapperCss = css`
padding: 10px;
`;
const titleCss = css`
color: ${theme.primary};
font-weight: ${bold ? 'bolder' : 'normal'};
font-size: 18px;
`;
const descriptionCss = css`
font-weight: ${bold ? 'bold' : 'normal'};
font-size: 12px;
`;
return (
<div css={wrapperCss}>
<h1 css={titleCss}>{title}</h1>
<div css={descriptionCss}>{description}</div>
</div>
);
} Just look at how it looks practically the same. I believe this is what resolves this issue, we don't plan to introduce any styled-based hooks. A custom babel transform could be created to support such syntax - but this is up to you. |
I suggested the same thing in styled-components.
Example syntax:
The main idea is to have a friendly syntax for Typescript. Sometimes, adding annotations for every
props: MyCompProps
can be overwhelming.The text was updated successfully, but these errors were encountered: