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 filtering to RNTester examples #22827

Closed
wants to merge 1 commit into from
Closed

Conversation

rickhanlonii
Copy link
Member

This PR adds filtering to the examples in RNTester. This will allow us to filter the examples directly instead of scrolling (which is unreliable). Note, this replaces #22777

Additionally, it also:

  • Adds and consolidates flow types for examples
  • Updates all examples to export title description and examples consistently
  • Refactors existing e2e tests to use the new filtering

Todo in a followup:

  • Refactor remaining modules that include multiple examples but do not export them individually (and thus cannot be filtered)

Test Plan:

Here is an example of one of the tests that now use filtering:

e2e

@facebook-github-bot facebook-github-bot added CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Tests This PR adds or edits a test case. labels Dec 29, 2018
@@ -67,6 +67,22 @@ class ToggleAnimatingActivityIndicator extends Component<
}
}

const styles = StyleSheet.create({
Copy link
Member Author

@rickhanlonii rickhanlonii Dec 29, 2018

Choose a reason for hiding this comment

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

In many of these files I moved the stylesheet declaration (or other code) above the example exports so that every example has the exports at the bottom for consistency

@@ -195,11 +195,6 @@ class Circle extends React.Component<any, any> {
}

class AnExApp extends React.Component<any, any> {
static title = 'Animated - Gratuitous App';
Copy link
Member Author

Choose a reason for hiding this comment

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

Many of the example files used static properties to declare the title and description. This didn't work great with flow types and is inconsistent with the other examples so I moved them all to the exports

@@ -14,20 +14,15 @@ const React = require('react');
const ReactNative = require('react-native');
const {DatePickerIOS, StyleSheet, Text, TextInput, View} = ReactNative;

class DatePickerExample extends React.Component<
class WithDatePickerData extends React.Component<
Copy link
Member Author

Choose a reason for hiding this comment

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

This needed refactored to export multiple examples

@@ -1,29 +0,0 @@
/**
Copy link
Member Author

Choose a reason for hiding this comment

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

I moved these types to shared/RNTesterTypes

static title = '<Picker>';
static description =
'Provides multiple options to choose from, using either a dropdown menu or a dialog.';
class BasicPickerExample extends React.Component<{}, $FlowFixMeState> {
Copy link
Member Author

Choose a reason for hiding this comment

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

Also needed to refactor this to export multiple examples

render(): React.Element<any> {
if (!this.props.module.examples) {
return <this.props.module />;
}

if (this.props.module.examples.length === 1) {
Copy link
Member Author

Choose a reason for hiding this comment

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

Here are the main changes in this pull

If there is only one example exported, we just show the single example. This should maintain the existing behavior for modules until they're refactored to export multiple examples.

If there's more than one example exported, we add a filter which will filter by the example title

@rickhanlonii
Copy link
Member Author

cc @CodingItWrong

@rickhanlonii
Copy link
Member Author

Spoke to @TheSavior and @CodingItWrong offline, closing this in favor of #22777 and breaking these changes out into multiple PRs

@zpao zpao deleted the rh-filter-e2e branch January 31, 2019 01:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Tests This PR adds or edits a test case.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants