过渡更顺畅?

时间:2017-01-28 15:28:00

标签: react-native

我有一个更普遍的问题。在我的应用程序上,我使用React Native Router Flux从一个页面移动到另一个页面。我注意到,根据页面,它将过渡更顺畅。特别是,当试图打开一个使用相机的页面时,过渡是不稳定和可怕的。显然有很多用处,因为相机被调出,一旦该页面加载,它的实时馈送就被加载到页面中。

有没有办法让这些过渡看起来很好,就像许多其他应用程序一样?是否有类似ComponentDidMount或构造函数的方法来避免逻辑?是否有一些策略可以实施。

任何建议都会令人难以置信!

1 个答案:

答案 0 :(得分:1)

您可以使用InteractionManager.runAfterInteractions回调延迟昂贵的渲染,直到当前转换完成。

class SomeView extends Component {
  state = {
    ready: false
  }

  componentDidMount() {
    InteractionManager.runAfterInteractions(() => {
      this.setState({ready: true})
    });
  }

  render() {
    if (!this.state.ready) {
      // render some placeholder view
    }

    // render the actual view
  }
}
相关问题