2016-09-21 401 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() 
    } 
相關問題