react-retrofit
A Retrofit like axios implementation for react native
Setup package.json
"dependencies": , "devDependencies": ,
Setup babel.config.js
plugins: "@babel/plugin-proposal-decorators" "legacy": true
Network Usage
// pass access_token to API refresh_token is optional /** * @param * @param */ @ { //transform data return access_token:dataaccess_token refresh_token:datarefresh_token } //This will be called when status 401 occurred //Please return axios or promise with access_token refresh_token is optional @ { return } /** * @param * @param */ @ { //transform data console return info } /** * @param * @param */ @ @Token //This will pass access_token to url automatically if @AUTH has been called { //transform data console return photo } const api = api api api
FlatList Usage
Component const item = { return <Text>name</Text> } /** * @param * @param * @param * @param */ @ //api return like [{"name":"Harry"},{"name":"Billy"}]. Attributes will auto bind to itemView { <thisMain /> }
FlatList With API Usage
id = 0 @ { return data } @ { thisid += 1 return data } const api = Component const item = { return <Text>name</Text> } /** * @param * @param {function name(data) {}} fetchAPI * @param {function name(data) {}} fetchNextAPI * @param * @param */ @ //api return like [{"name":"Harry"},{"name":"Billy"}]. Attributes will auto bind to itemView { <thisMain /> }