-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
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
[docs] Polish Snackbar demos #15129
[docs] Polish Snackbar demos #15129
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,14 +25,10 @@ export interface State { | |
Transition?: React.ComponentType<TransitionProps>; | ||
} | ||
|
||
class DirectionSnackbar extends React.Component<void, State> { | ||
constructor() { | ||
super(); | ||
|
||
this.state = { | ||
open: false, | ||
}; | ||
} | ||
class DirectionSnackbar extends React.Component<{}, State> { | ||
state: State = { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The generic argument in |
||
open: false, | ||
}; | ||
|
||
handleClick = (Transition: React.ComponentType<TransitionProps>) => () => { | ||
this.setState({ open: true, Transition }); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,10 +4,6 @@ import Button from '@material-ui/core/Button'; | |
import { SnackbarProvider, VariantType, withSnackbar, withSnackbarProps } from 'notistack'; | ||
|
||
class App extends React.Component<withSnackbarProps> { | ||
static propTypes = { | ||
enqueueSnackbar: PropTypes.func.isRequired, | ||
}; | ||
|
||
handleClick = () => { | ||
this.props.enqueueSnackbar('I love snacks.'); | ||
}; | ||
|
@@ -27,6 +23,10 @@ class App extends React.Component<withSnackbarProps> { | |
} | ||
} | ||
|
||
(App as React.ComponentClass<withSnackbarProps>).propTypes = { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is quite ugly but it's the pattern we use throughout the codebase. Allows separation of interface and implementation and doesn't block readability (usually what we're interested in first is |
||
enqueueSnackbar: PropTypes.func.isRequired, | ||
}; | ||
|
||
const MyApp = withSnackbar(App); | ||
|
||
function IntegrationNotistack() { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was an unsafe cast. It allowed
messageInfo.message.length
while it might throw at runtime if the queue is empty.