react-native-navigator-router 整合 ReactNative 和 Rea开源项目

我要开发同款
匿名用户2016年05月27日
65阅读
开发技术JavaObject-c
所属分类程序开发
授权协议MIT

作品详情

本项目用来整合ReactNative和ReactRouter两个组件。ReactNative中提供了页面栈管理和导航的组件Navigator,为页面的生命周期管理和页面导航跳转提供了动画容器的支持。ReactRouter提供了为React项目的路由导航支持。通过使用ReactNativeNavigatorRouter可以将两个组件整合起来,在ReactNative项目中实现根据URL进行界面导航跳转,并且拥有近乎原生效果的动画。

使用方式很简单:

import React, { Component } from 'react';import { AppRegistry } from 'react-native';import { createMemoryHistory, Router, IndexRoute, Route } from 'react-router';import { createNavigatorRouter } from 'react-native-navigator-router';class App extends Component {  render() {    return (      <Router history={createMemoryHistory('/')}>        <Route path='/' component={createNavigatorRouter()}>          <IndexRoute component={Home} />          <Route path="/about" component={About} />          <Route path="/detail" component={Detail} />        </Route>      </Router>    );  }}AppRegistry.registerComponent('Example', () => App);

需要跳转到新页面时,只需要使用ReactRouter进行转跳即可:

this.context.router.push('/about')

目前该组件以及应用于生产环境的App中,并已经在市场上架。

声明:本文仅代表作者观点,不代表本站立场。如果侵犯到您的合法权益,请联系我们删除侵权资源!如果遇到资源链接失效,请您通过评论或工单的方式通知管理员。未经允许,不得转载,本站所有资源文章禁止商业使用运营!
下载安装【程序员客栈】APP
实时对接需求、及时收发消息、丰富的开放项目需求、随时随地查看项目状态

评论