Coder Social home page Coder Social logo

nihgwu / react-native-dva-starter Goto Github PK

View Code? Open in Web Editor NEW
643.0 643.0 149.0 1.44 MB

a React Native starter powered by dva and react-navigation

JavaScript 64.28% Python 8.61% Java 7.02% Objective-C 20.09%
dva react-native react-navigation starter

react-native-dva-starter's Introduction

react-native-dva-starter

A React Native starter powered by dva and react-navigation

Start

npm install dva-native-cli -g
dvanative git app
cd app
react-native run-ios # or react-native run-android

Great thanks to @xuan45 for his cli tool dva-native-cli, check that project for more information.

Advance

The builtin router of dva (not react-router v4), doesn't support React Native, we have to integrate other router components, such as Navigator, ExperimentalNavigation, react-native-router-flux and react-navigation. Since the former two will be depreciated in flavor of react-navigation, which is also be recommended by official, so I choose it to be the navigator.

In this starter, I provide a router model to control the default action flow of react-navigation to workaround a known issue. If you don't need this, the integration will be much simpler, you can simply remove the router model and pass routerReducer to extraReducer of dva extraReducers: { router: routerReducer }. Read Redux Integration and dva's API for more information.

Also there is another workaround for a missing feature react-navigation/react-navigation#232, so I use two StackNavigators to contain the screens with different transition animations, you can create you own transition animations via transitionConfig, see react-navigation/react-navigation#99

LICENSE

MIT

react-native-dva-starter's People

Contributors

flasco avatar nihgwu avatar qwlong avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-native-dva-starter's Issues

*Drawer() 失效

In this starter, I provide a router model to control the default action flow of react-navigation to workaround a known issue. If you don't need this, the integration will be much simpler, you can simply remove the router model and pass routerReducer to extraReducer of dva extraReducers: { router: routerReducer }. Read Redux Integration and dva's API for more information.

如果用router model, Drawer -> this.props.navigation.dispatch(DrawerActions.toggleDrawer()) 会不起作用

New React-Navigation integration

They added...

import {
  createReduxBoundAddListener,
  createReactNavigationReduxMiddleware,
} from 'react-navigation-redux-helpers';

should update and do some modification, Thanks

popToTop无效

this.props.navigation.popToTop();
好像是升级了react-navigation v2的原因。

如何用expo和Genymotion预览应用

直接run-android报错FAILURE: Build failed with an exception.。而用Expo XDE也不行,说Missing app.json,往里面加入对应expo信息后又报Cannot find module 'D:\Coding\work\...\node_modules\expo\tools\LogReporter'。然后就卡在这里了。

如何才能用expo预览应用,或者还有其他什么方式能方便开发时预览?

Question: Why do you use dispatch instead of navigate?

I wonder why you use longer form:

import {NavigationActions} from 'react-navigation'
...
this.props.dispatch(NavigationActions.navigate({routeName: 'HomeScreen'}));

Is there a problem with the code below?

this.props.navigation.navigate('HomeScreen');

Do we really need, importing NavigationActions for each time we need navigation

打开同一个页面问题

  1. 运行DEMO
  2. 点Goto Detail
  3. 再继续点Goto Detail 不再会有页面切换动画,好像一直在替换当前页面

react-navigation SET_PARAMS参数不能传递方法

现在需要在导航栏右侧加一个按钮。
_onDrawerOpenHide() { this._drawer.Open(); }

componentDidMount() { this.props.navigation.setParams({ navigatePress: this._onDrawerOpenHide }) }
用这种方式获取不了
navigation.state.params.navigatePress()

请问有什么好的解决方案吗?

升级以后在报错,ios

`
Unpacking /Users/kalaliu/.rncache/boost_1_63_0.tar.gz...

tar: (Empty error message)

tar: Error exit delayed from previous errors.

Command /bin/sh failed with exit code 1

** BUILD FAILED **

The following commands produced analyzer issues:

Analyze /Users/kalaliu/temp/react-native-dva-starter/node_modules/react-native/ReactCommon/yoga/yoga/Yoga.c
Analyze /Users/kalaliu/temp/react-native-dva-starter/node_modules/react-native/ReactCommon/yoga/yoga/YGNodeList.c

(2 commands with analyzer issues)

The following build commands failed:
PhaseScriptExecution Install\ Third\ Party /Users/kalaliu/temp/react-native-dva-starter/ios/build/Build/Intermediates/React.build/Debug-iphonesimulator/double-conversion.build/Script-190EE32F1E6A43DE00A8543A.sh
(1 failure)

Installing build/Build/Products/Debug-iphonesimulator/DvaStarter.app
An error was encountered processing the command (domain=NSPOSIXErrorDomain, code=2):
Failed to install the requested application
An application bundle was not found at the provided path.
Provide a valid path to the desired application bundle.
Print: Entry, ":CFBundleIdentifier", Does Not Exist

Command failed: /usr/libexec/PlistBuddy -c Print:CFBundleIdentifier build/Build/Products/Debug-iphonesimulator/DvaStarter.app/Info.plist
Print: Entry, ":CFBundleIdentifier", Does Not Exist
`

undefined is not an object(evaluating '_ref.routes')

在新添一个tab后就报错,不知为何,google没搜到这个问题,
只在react-navigation看到这个issue1408
但还是不知道怎么解决,求助~

const HomeNavigator = TabNavigator(
  {
    Home: { screen: Home },
    Account: { screen: Account },
    Msg: { screen: Msg}, //新添一个tab
  },
  {
    tabBarComponent: TabBarBottom,
    tabBarPosition: 'bottom',
    swipeEnabled: false,
    animationEnabled: false,
    lazyLoad: true,
  },
)

could not release apk when change enableProguardInReleaseBuilds=true,

steps:
1.clone the code from git,
2.npm i &react-native link
3.add keystore to android and change configuration
4. cd android & ./gradlew aR ==>successful

5.change the android/app/build.gradle

def enableProguardInReleaseBuilds = false

to

def enableProguardInReleaseBuilds = true
  1. cd android & ./gradlew aR . ===>failed
Note: the configuration keeps the entry point 'okio.ForwardingSource { ForwardingSource(okio.Source); }', but not the descriptor class 'okio.Source'
Note: the configuration keeps the entry point 'okio.ForwardingSource { long read(okio.Buffer,long); }', but not the descriptor class 'okio.Buffer'
Note: there were 2 references to unknown classes.
      You should check your configuration for typos.
      (http://proguard.sourceforge.net/manual/troubleshooting.html#unknownclass)
Note: there were 676 unkept descriptor classes in kept class members.
      You should consider explicitly keeping the mentioned classes
      (using '-keep').
      (http://proguard.sourceforge.net/manual/troubleshooting.html#descriptorclass)
Note: there were 7 unresolved dynamic references to classes or interfaces.
      You should check if you need to specify additional program jars.
      (http://proguard.sourceforge.net/manual/troubleshooting.html#dynamicalclass)
Note: there were 1 accesses to class members by means of introspection.
      You should consider explicitly keeping the mentioned class members
      (using '-keep' or '-keepclassmembers').
      (http://proguard.sourceforge.net/manual/troubleshooting.html#dynamicalclassmember)
Warning: there were 1 unresolved references to library class members.
         You probably need to update the library versions.
         (http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedlibraryclassmember)
Warning: Exception while processing task java.io.IOException: Please correct the above warnings first.
:app:transformClassesAndResourcesWithProguardForRelease FAILED

Take DrawerNavigator as the root navigator, not the stackNavigator

hi:
i found one wired thing here, when i take DrawerNavigator as the root navigator, not the stackNavigator, the drawerNavigator will does not work as it expected!
the issue is when i click one of the drawer item, thing happened, not go to the corresponding page maped to the drawerNavigator!
is somethign i missed or ?

Why you removed redux-persist ?

redux-persist v5 support new use cases :

  • code splitting reducers
  • easier to ship persist support inside of other libs (e.g. redux-offline)
  • ability to colocate persistence rules with the reducer it pertains to
  • first class migration support
  • enable PersistGate react component which blocks rendering until persistence is complete (and enables similar patterns for integration)
  • possible to nest persistence
  • gaurantee consistent state atoms
  • better debugability and extensibility

Update README

Change react-native start-ios => react-native run-ios

在route.js中怎么添加一个页面在home页前面

感谢回复,我将附件中红框的代码调换了位置,Login页面只闪现了一下就自己跳到home页了,我想知道在route.js中怎么添加一个页面在home页前面,Login不要是react-navigation的中页面,单独的页面,感谢回复,万分谢谢。
const AppNavigator = StackNavigator(
{
//Login: { screen: Login },
//Main: { screen: MainNavigator },
Login: { screen: Login },
Main: { screen: MainNavigator },
},

如何在store中加入redux-persist

我在createDva.js中修改了 ,但是不起效
image
如能帮助 不胜感激,
还有一个问题 如果我有多个tabnavigator 该怎么和redux进行关联

我直接clone下代码,然后npm install,出错,请问如何解决

你好,以下是出错的信息,谢谢!
npm ERR! Darwin 16.3.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install"
npm ERR! node v4.6.0
npm ERR! npm v2.15.9
npm ERR! code EPEERINVALID

npm ERR! peerinvalid The package [email protected] does not satisfy its siblings' peerDependencies requirements!
npm ERR! peerinvalid Peer [email protected] wants [email protected]
npm ERR! peerinvalid Peer [email protected] wants [email protected]
npm ERR! peerinvalid Peer [email protected] wants react@*
npm ERR! peerinvalid Peer [email protected] wants react@^15.4.2

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.