Write code for React Web and React Native using one simple framework. Maximizes code re-use, readability, and wraps necessary functions into promises.
Note: this repository is currently under construction. Please contribute!
Install:
npm install react-cross-platform --save
Usage:
import {notify, storage, fetch, etc...} from 'react-cross-platform';
//or
import * as rcp from 'react-cross-platform'
fetch : create web request
//takes ajax options object or native fetch options object
//use detect.web/native to determine which options to send
fetch(url, options)
.then(data => { console.log(data) })
.catch(err => { console.log(err.message) });
notify : alert the user with a popup notification
notify('Hello World!', () => console.log('done'));
navigate : render a page component
//navigate to specified route
navigate('home', this.props);
storage : persistent key value/object store
//get item
storage.set('prices', {gumbo: 9.99, boudin: 4.99}).then(() => {
console.log('prices saved');
});
storage.get('prices').then(product => {
notify(`Boudin for ${product.boudin}!`);
});
storage.remove('prices').then(() => {
console.log('no more boudin');
});
Modules and Status:
- appstate: done
- confirm: done
- confirmYesNo: done
- detect: done
- fcm: done
- fetch: done
- googleSignIn: done
- linking: done
- navigate: done
- nativeModules: done
- notify: in progress - promisify
- platform: done
- storage: done
- appstate: done
- confirm: done
- confirmYesNo: done
- detect: done
- fcm: done
- fetch: done
- googleSignIn: done
- linking: done
- navigate: done
- nativeModules: done
- notify: in progress - promisify
- platform: done
- storage: done