2016-09-21 392 views
1

我在使用RN 0.33和NavigationExperimental实现平滑过渡时遇到了问题。我看到的问题是呈现的场景渲染相对昂贵,并且NavigationExperimental保留了两个场景的过渡。我想知道什么是优化这个过程的好策略。导航实验波涛汹涌的过渡

到目前为止我所做的是在导航组件中有一个'isAnimating'状态,它将场景组件的shouldComponentUpdate设置为false。

回答

1

我有这个问题,并且转换中丢失的帧是由于获取数据以及组件过去的componentDidMount中的后续渲染导致的。

您可以在componentDidMount中使用InteractionManager,以便只在任何动画或转换完成后才能运行提取代码。

例如:

import { InteractionManager } from 'react-native' 

    componentDidMount() { 
    this.interaction = InteractionManager.runAfterInteractions(() => {   
     performExpensiveFetch() 
    }) 
    } 

    componentWillUnmount() { 
    if(this.interaction) this.interaction.cancel() 
    } 
相关问题