Skip to content
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

withStyles in Typescript, Props classes non nullable? #8267

Closed
1 task done
nilem opened this issue Sep 18, 2017 · 4 comments
Closed
1 task done

withStyles in Typescript, Props classes non nullable? #8267

nilem opened this issue Sep 18, 2017 · 4 comments

Comments

@nilem
Copy link

nilem commented Sep 18, 2017

  • I have searched the issues of this repository and believe that this is not a duplicate.

Expected Behavior

We are using withStyle() to overload our components and access classes at rendering. Note that I am unsure we were using it the way it was intended to be. Please check the code below for a quick example.

const styles = {
  logo: {
    maxWidth: '420px',
  },
};

export interface IProps {
  readonly classes?: any;
}

class ExampleComp extends React.Component<IProps, {}> {
  public render(): JSX.Element {
    return(<Grid item sm={12} className={classes.logo}>&nbsp;</Grid>);
  }
}

export default withStyles(styles)(ExampleComp);

Current Behavior

Since beta10 and Pull Request #8178, ExampleComp signature throw an exception when overload by withStyle() as the props Classes cannot be nullable. Problem : this is forcing us to pass a dummy classes props when calling the component.

Is it normal that classes is not nullable?

Your Environment

Typescript / Visual Studio Code

Tech Version
Material-UI beta10
React 15.6
@nilem
Copy link
Author

nilem commented Sep 18, 2017

Just saw the beta11, but it doesn't fix my issue since "classes" is still not nullable
https://github.com/callemall/material-ui/blob/v1-beta/src/styles/withStyles.d.ts

@ssalbdivad
Copy link

Having the same issue, although just updating "classes" to be nullable in withStyles.d.ts locally seems to resolve the issue relatively cleanly. It seems like the only other workaround requires passing classes as a prop everywhere. Maybe an easy fix?

@nilem
Copy link
Author

nilem commented Sep 22, 2017

Thanks for the PR @ssalbdivad ! I guess we can close here.

@nilem nilem closed this as completed Sep 22, 2017
@pelotom
Copy link
Member

pelotom commented Sep 22, 2017

Probably shouldn't close this until a PR that resolves it is actually merged...

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

No branches or pull requests

4 participants