npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

dva-native

v0.2.2

Published

encapsulating react-navigation, dva-core, axios and mockjs for react-native

Downloads

17

Readme

dva-native

encapsulating [email protected], dva, axios and Mock.js for react-native

You can use dva-native-cli

Start

npm install --save dva-native

// for [email protected]
npm install --save [email protected]

Api

Export Files

dva-native

Default export file

import createApp, { connect } from 'dva-native';

dva-native/navigation

Export the api of [email protected]

import { ... } from 'dva-native/navigation';

dva-native/axios

Async request library, export axios

import axios, { createLogger } from 'dva-native/axios';
// if you want to print the request log
createLogger(axios);

dva-native/mock

Export Mock.js

import Mock from 'dva-native/mock';

dva-native/dynamic

Load components on dynamic. For convenience debug, only in production mode. metro is commonJs standard. If you want to split bundle, use react-native unbundle in android

import dynamic from 'dva-native/dynamic';

const DynamicComponent = dynamic({
    app, // dva instance
    models: () => [require('./models/user')], // dva model
    component: () => require('./pages/Page'), // React Component
});

dva-native/codePushConfig

If use react-native-code-push, Configuring some environmental params, but codePush.getConfiguration is a Promise. You may not be able to get it in time

import codePushConfig from 'dva-native/codePushConfig';

app.config(codePushConfig({
    'code-push-key': { ...code push config }
})({
    ...base config
}))

app.getConfig()

dva-native API

createApp.setGlobalError

Call ErrorUtils.setGlobalHandler. Reset Capture javascript errors, only in production mode

// If you use react-native-sentry, must Call before it
createApp.setGlobalError(function(error, isFatal){ ... })
Sentry.config('xxx').install();

createApp.onGlobalError

Add listener for javascript error

createApp.onGlobalError(function(error, isFatal){ ... })

dynamic.setErrorComponent

If you run js context error and use setGlobalError, set a ErrorComponent to show

dynamic.setErrorComponent(React Component)

app = createApp(...dva opts)(getAppNavigator)

Create dva instance

If use react-navigation, getAppNavigator must return Navigator

(getApp) => {
	const wrapper = (models, component) => dynamic({ 
	    app: getApp, models, component 
	});
	return createStackNavigator({
	    Page: {
	    	screen: wrapper(() => [require('./models/user')], () => require('./pages/Page')) 
	    }
	})
}

app.config

Configure some params

app.config(({ app }) => ({ ...config }))
// or
app.config(codePushConfig({ ... })({ ...config }))

app.getConfig

Return config params

app.getConfig()

app.root

This is necessary, and must return React Component

app.root(({ Router, app }) => {
	return class Root extends Component {
		render() {
			return <Router/>
		}
	}
})

app.start

Register Root Component

AppRegistry.registerComponent('xxx', app.start);

...all dva instance API