Filter out active prop on dummy screen component

This commit is contained in:
Brent Vatne 2018-08-24 10:06:37 -07:00
parent eebe65631e
commit 6a0c6de329
4 changed files with 23 additions and 21 deletions

View File

@ -44,7 +44,6 @@ exports[`Nested navigators renders succesfully as direct child 1`] = `
<View <View
accessibilityElementsHidden={false} accessibilityElementsHidden={false}
accessible={true} accessible={true}
active={1}
collapsable={undefined} collapsable={undefined}
pointerEvents="auto" pointerEvents="auto"
style={ style={
@ -118,7 +117,6 @@ exports[`Nested navigators renders succesfully as direct child 1`] = `
<View <View
accessibilityElementsHidden={false} accessibilityElementsHidden={false}
accessible={true} accessible={true}
active={1}
collapsable={undefined} collapsable={undefined}
pointerEvents="auto" pointerEvents="auto"
style={ style={

View File

@ -44,7 +44,6 @@ exports[`StackNavigator applies correct values when headerRight is present 1`] =
<View <View
accessibilityElementsHidden={false} accessibilityElementsHidden={false}
accessible={true} accessible={true}
active={1}
collapsable={undefined} collapsable={undefined}
pointerEvents="auto" pointerEvents="auto"
style={ style={
@ -240,7 +239,6 @@ exports[`StackNavigator renders successfully 1`] = `
<View <View
accessibilityElementsHidden={false} accessibilityElementsHidden={false}
accessible={true} accessible={true}
active={1}
collapsable={undefined} collapsable={undefined}
pointerEvents="auto" pointerEvents="auto"
style={ style={

View File

@ -3,7 +3,6 @@ import { StyleSheet, Platform } from 'react-native';
import { Screen } from './screens'; import { Screen } from './screens';
import createPointerEventsContainer from './createPointerEventsContainer'; import createPointerEventsContainer from './createPointerEventsContainer';
/* eslint-disable no-unused-vars */
const EPS = 1e-5; const EPS = 1e-5;
function getAccessibilityProps(isActive) { function getAccessibilityProps(isActive) {
@ -30,28 +29,22 @@ class Card extends React.Component {
children, children,
pointerEvents, pointerEvents,
style, style,
// position, position,
scene: { /* index, */ isActive }, scene: { index, isActive },
} = this.props; } = this.props;
// If we use react-native <= 0.55, we can't call position.__makeNative() const active = position.interpolate({
// before binding this value to the view. If we use >= 0.56, then we have inputRange: [index, index + 1 - EPS, index + 1],
// to call position.__makeNative(). Unclear to me what is happening here outputRange: [1, 1, 0],
// so temporarily commented this out. extrapolate: 'clamp',
// });
// const active = position.interpolate({
// inputRange: [index, index + 1 - EPS, index + 1],
// outputRange: [1, 1, 0],
// extrapolate: 'clamp',
// });
return ( return (
<Screen <Screen
pointerEvents={pointerEvents} pointerEvents={pointerEvents}
ref={this.props.onComponentRef} onComponentRef={this.props.onComponentRef}
style={[styles.main, style]} style={[styles.main, style]}
// active={active} active={active}
active={isActive ? 1 : 0}
{...getAccessibilityProps(isActive)} {...getAccessibilityProps(isActive)}
> >
{children} {children}

View File

@ -1,6 +1,19 @@
import React from 'react';
import { Animated, View } from 'react-native'; import { Animated, View } from 'react-native';
const ScreenContainer = View; const ScreenContainer = View;
const Screen = Animated.View;
class Screen extends React.Component {
render() {
// Filter out active prop in this case because it is unused and
// can cause problems depending on react-native version:
// https://github.com/react-navigation/react-navigation/issues/4886
/* eslint-disable no-unused-vars */
const { active, onComponentRef, ...props } = this.props;
return <Animated.View {...props} ref={onComponentRef} />;
}
}
export { ScreenContainer, Screen }; export { ScreenContainer, Screen };