-
Notifications
You must be signed in to change notification settings - Fork 24.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
Add filtering to RNTester examples #22827
Conversation
@@ -67,6 +67,22 @@ class ToggleAnimatingActivityIndicator extends Component< | |||
} | |||
} | |||
|
|||
const styles = StyleSheet.create({ |
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.
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'; |
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.
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< |
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 needed refactored to export multiple examples
@@ -1,29 +0,0 @@ | |||
/** |
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.
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> { |
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.
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) { |
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.
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
Spoke to @TheSavior and @CodingItWrong offline, closing this in favor of #22777 and breaking these changes out into multiple PRs |
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:
title
description
andexamples
consistentlyTodo in a followup:
Test Plan:
Here is an example of one of the tests that now use filtering: