Skip to content

ThemeProp should not be optional #42

Open

Description

@thegurneet

The ThemeProp needs to be changed from optional to required if the ThemeProvider has theme as required.

This is causing props to be either DefaultTheme | undefined, when a theme is clearly defined.

Screenshot 2022-11-07 at 14 15 17
Screenshot 2022-11-07 at 14 16 55

Activity

  1. specialdoom commented on Nov 30, 2022

    @specialdoom

    Anything on this?

  2. mlaopane commented on Dec 29, 2022

    @mlaopane

    When using a function, I'm not sure there is a way to figure out automatically what is the type of theme
    (you might have not initialized the theme in the first place).

    Ideally the type should be inferred when providing it as a generic type.

    const myTheme = {
      color: {
        backgroundColor: '#123'
      }
    }
    const SomeText = styled("div")<{ theme: typeof myTheme }>``;

    PS : Please do not provide only screenshots when opening an issue 🙏🏽

  3. thegurneet commented on Jan 12, 2023

    @thegurneet
    Author

    The screenshot in this instance provided enough information.

    `const SomeText = styled("div")<{ theme: typeof myTheme }>``

    Defining the theme like this is wrong. For each no styled component I will have to define the theme as typeof myTheme.

    The documentation solid-styled-components is based of: https://styled-components.com/docs/advanced

    The theme is always defined by default, we simply extend onto it by giving it more props.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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