Stop using animated value for active prop temporarily due to https://github.com/react-navigation/react-navigation/issues/4886

This commit is contained in:
Brent Vatne 2018-08-23 16:19:13 -07:00
parent 17e8797ef1
commit ad0696183c
2 changed files with 17 additions and 22 deletions

View File

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

View File

@ -1,18 +1,9 @@
import React from 'react';
import {
Animated,
NativeModules,
Easing,
StyleSheet,
View,
} from 'react-native';
import { Animated, Easing, StyleSheet, View } from 'react-native';
import invariant from '../utils/invariant';
import NavigationScenesReducer from './ScenesReducer';
const NativeAnimatedModule =
NativeModules && NativeModules.NativeAnimatedModule;
// Used for all animations unless overriden
const DefaultTransitionSpec = {
duration: 250,
@ -47,10 +38,6 @@ class Transitioner extends React.Component {
),
};
if (NativeAnimatedModule) {
this.state.position.__makeNative();
}
this._prevTransitionProps = null;
this._transitionProps = buildTransitionProps(props, this.state);
this._isMounted = false;