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

Add Drawer #13

Merged
merged 1 commit into from
Aug 10, 2016
Merged

Add Drawer #13

merged 1 commit into from
Aug 10, 2016

Conversation

alitaheri
Copy link
Collaborator

No description provided.

@mattiamanzati mattiamanzati mentioned this pull request Aug 9, 2016
39 tasks
@@ -0,0 +1,23 @@
import * as React from 'react'

export type DrawerChangeReason = 'swipe' | 'clickaway' | 'escape';
Copy link
Owner

@mattiamanzati mattiamanzati Aug 9, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is that used outside? Since it's a union of constant string is it really useful to export it?

Copy link
Collaborator Author

@alitaheri alitaheri Aug 9, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since it's only used in a callback, people might want to strong type it, something like:

class Component extends React.Component<any, any> {

  // If we don't export the type people will have to manually declare the type
  // or it will be inferred as any. This is error-prone.
  private handleOnChange = (opening: boolean, reason: DrawerChangeReason) => {
    ...
  };

  render() {
    // also, inlining the function will hurt shallow equal optimizations.
    return <Drawer onRequestChange={this.handleOnChange}/>;
  }
}

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, seems right!

@alitaheri alitaheri merged commit 49329e5 into mattiamanzati:master Aug 10, 2016
@alitaheri alitaheri deleted the add-drawer branch August 10, 2016 05:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants