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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[EventListener] Remove deprecated lifecycle method #628

Merged
merged 3 commits into from Nov 21, 2018
Merged

Conversation

AndrewMusgrave
Copy link
Member

WHY are these changes introduced?

Part of #519

WHAT is this pull request doing?

  • Replaces lifecycle method
  • Add test

How to 馃帺

Copy-paste this code in playground/Playground.tsx:
import * as React from 'react';
import {Page, AppProvider, Button, EventListener} from '@shopify/polaris';

interface State {
  event: 'resize' | 'scroll';
}

export default class CollapsibleExample extends React.Component<never, State> {
  state: State = {
    event: 'resize',
  };

  render() {
    const {event} = this.state;
    const lines = Array.from({length: 100}, (n: number) => <br key={n} />);

    return (
      <AppProvider>
        <Page title="test">
          <EventListener event={event} handler={() => console.log(event)} />
          <Button onClick={this.handleToggleClick}>
            Current listener {event}
            <br />
            Previous listener {this.getEvent()}
          </Button>
          {lines}
        </Page>
      </AppProvider>
    );
  }

  handleToggleClick = () => {
    this.setState({event: this.getEvent()});
  };

  getEvent() {
    const {event} = this.state;
    return event === 'scroll' ? 'resize' : 'scroll';
  }
}

@BPScott BPScott temporarily deployed to polaris-react-pr-628 November 15, 2018 20:48 Inactive
@BPScott BPScott temporarily deployed to polaris-react-pr-628 November 15, 2018 20:51 Inactive
@solonaarmstrong-zz
Copy link

I 馃帺 with Popover and 馃憤 Code makes sense. Just needs a rebase.

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.

None yet

4 participants