Last active
December 1, 2017 12:33
-
-
Save lucasfernandes/1a9c03dcdac942f3f4ef0880ce4d6eaf to your computer and use it in GitHub Desktop.
Visual Studio Code - This package offers some snippets for working with React Native course boilerplate - GoNative
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// javascriptreact.json | |
// <==== REMEMBER TO ADD THE CONTENT ABOVE IN THE SPECIFIC FILE ON VSCODE ====> | |
{ | |
/* | |
// Place your snippets for JavaScript React here. Each snippet is defined under a snippet name and has a prefix, body and | |
// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are: | |
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the | |
// same ids are connected. | |
// Example: | |
"Print to console": { | |
"prefix": "log", | |
"body": [ | |
"console.log('$1');", | |
"$2" | |
], | |
"description": "Log output to console" | |
} | |
*/ | |
"apisauce": { | |
"prefix": "apisauce", | |
"body": [ | |
"import { create } from 'apisauce';", | |
"", | |
"const api = create({", | |
" baseURL: '${1:http://localhost:3000}',", | |
" headers: {", | |
" Accept: 'application/vnd.github.v3+json',", | |
" 'User-Agent': 'Githuber',", | |
" },", | |
"});", | |
"", | |
"export default api;" | |
], | |
"description": "Create APISauce Config" | |
}, | |
"component": { | |
"prefix": "component", | |
"body": [ | |
"/* Core */", | |
"import React, { Component } from 'react';", | |
"import PropTypes from 'prop-types';", | |
"", | |
"/* Presentational */", | |
"import { View } from 'react-native';", | |
"", | |
"// import styles from './styles';", | |
"", | |
"export default class ${1:MyComponent} extends Component {", | |
" static propTypes = {};", | |
"", | |
" static defaultProps = {};", | |
"", | |
" static state = {}", | |
"", | |
" render() {", | |
" return (", | |
" <View />", | |
" );", | |
" }", | |
"}", | |
"" | |
], | |
"description": "Create react-native component" | |
}, | |
"proptypes": { | |
"prefix": "proptypes", | |
"body": [ | |
"static propTypes = {", | |
" ${1}", | |
"};" | |
], | |
"description": "Create component propTypes" | |
}, | |
"defaultprops": { | |
"prefix": "defaultprops", | |
"body": [ | |
"static defaultProps = {", | |
" ${1}", | |
"};" | |
], | |
"description": "Create component defaultProps" | |
}, | |
"reactotronconfig": { | |
"prefix": "reactotronconfig", | |
"body": [ | |
"import Reactotron from 'reactotron-react-native';", | |
"", | |
"if (__DEV__) {", | |
" const tron = Reactotron", | |
" .configure()", | |
" .useReactNative()", | |
" .connect();", | |
"", | |
" tron.clear();", | |
"", | |
" console.tron = tron;", | |
"}" | |
], | |
"description": "Create Reactotron Config" | |
}, | |
"reactotronredux": { | |
"prefix": "reactotronredux", | |
"body": [ | |
"import Reactotron from 'reactotron-react-native';", | |
"import { reactotronRedux } from 'reactotron-redux';", | |
"import sagaPlugin from 'reactotron-redux-saga';", | |
"", | |
"if (__DEV__) {", | |
" const tron = Reactotron", | |
" .configure()", | |
" .useReactNative()", | |
" .use(reactotronRedux())", | |
" .use(sagaPlugin())", | |
" .connect();", | |
"", | |
" tron.clear();", | |
"", | |
" console.tron = tron;", | |
"}" | |
], | |
"description": "Create Reactotron Config" | |
}, | |
"duck": { | |
"prefix": "duck", | |
"body": [ | |
"import { createReducer, createActions } from 'reduxsauce';", | |
"import Immutable from 'seamless-immutable';", | |
"", | |
"/* Types & Action Creators */", | |
"", | |
"const { Types, Creators } = createActions({", | |
"// actionType: ['dataPassed'],", | |
"});", | |
"", | |
"export const ${1:name}}Types = Types;", | |
"export default Creators;", | |
"", | |
"/* Initial State */", | |
"", | |
"export const INITIAL_STATE = Immutable({", | |
"// data: [],", | |
"});", | |
"", | |
"/* Reducers */", | |
"", | |
"// export const reducer = state =>", | |
"// state.merge({ data: [] });", | |
"", | |
"/* Reducers to types */", | |
"", | |
"export const reducer = createReducer(INITIAL_STATE, {", | |
"// [Types.ACTION_TYPE]: reducer,", | |
"});" | |
], | |
"description": "Create react-native duck module" | |
}, | |
"render": { | |
"prefix": "render", | |
"body": [ | |
"render() {", | |
" return (", | |
" ${1:<View />}", | |
" );", | |
"}" | |
], | |
"description": "Create render method" | |
}, | |
"mapDispatchToProps": { | |
"prefix": "mapDispatchToProps", | |
"body": [ | |
"const mapDispatchToProps = dispatch => ({", | |
" ${1}", | |
"});" | |
], | |
"description": "Create redux mapDispatchToProps" | |
}, | |
"mapStateToProps": { | |
"prefix": "mapStateToProps", | |
"body": [ | |
"const mapStateToProps = state => ({", | |
" ${1}", | |
"});" | |
], | |
"description": "Create redux mapStateToProps" | |
}, | |
"reduxComponent": { | |
"prefix": "reduxComponent", | |
"body": [ | |
"/* Core */", | |
"import React, { Component } from 'react';", | |
"", | |
"/* Presentational */", | |
"import { View } from 'react-native';", | |
"", | |
"/* Redux */", | |
"import { connect } from 'react-redux';", | |
"", | |
"// import styles from './styles';", | |
"", | |
"class ${1:MyComponent} extends Component {", | |
" render() {", | |
" return (", | |
" <View />", | |
" );", | |
" }", | |
"}", | |
"", | |
"const mapStateToProps = state => ({", | |
"", | |
"});", | |
"", | |
"const mapDispatchToProps = dispatch => ({", | |
"", | |
"});", | |
"", | |
"export default connect(mapStateToProps, mapDispatchToProps)(${1:MyComponent});", | |
"" | |
], | |
"description": "Create react-native Redux component" | |
}, | |
"configureStore": { | |
"prefix": "configureStore", | |
"body": [ | |
"import { createStore, applyMiddleware, compose } from 'redux';", | |
"", | |
"export default (rootReducer) => {", | |
" const middleware = [];", | |
" const enhancers = [];", | |
"", | |
" /* Saga */", | |
" // const sagaMonitor = __DEV__ ? console.tron.createSagaMonitor() : null;", | |
" // const sagaMiddleware = createSagaMiddleware({ sagaMonitor });", | |
" // middleware.push(sagaMiddleware);", | |
"", | |
" enhancers.push(applyMiddleware(...middleware));", | |
"", | |
" /* Store */", | |
" const createAppropriateStore = __DEV__ ? console.tron.createStore : createStore;", | |
" const store = createAppropriateStore(rootReducer, compose(...enhancers));", | |
"", | |
" /* Run Saga */", | |
" // sagaMiddleware.run(rootSaga);", | |
"", | |
" return store;", | |
"};" | |
], | |
"description": "Create configureStore file" | |
}, | |
"storeWithSaga": { | |
"prefix": "storeWithSaga", | |
"body": [ | |
"import { createStore, applyMiddleware } from 'redux';", | |
"import createSagaMiddleware from 'redux-saga';", | |
"import { persistStore, persistCombineReducers } from 'redux-persist';", | |
"import storage from 'redux-persist/es/storage';", | |
"import sagas from './sagas';", | |
"", | |
"import reducers from './ducks';", | |
"", | |
"const rootReducer = persistCombineReducers({", | |
" key: 'root',", | |
" storage,", | |
"}, reducers);", | |
"", | |
"const sagaMonitor = __DEV__ ? console.tron.createSagaMonitor() : null;", | |
"const sagaMiddleware = createSagaMiddleware({ sagaMonitor });", | |
"", | |
"const middleware = [sagaMiddleware];", | |
"", | |
"const createApropriateStore = __DEV__ ? console.tron.createStore : createStore;", | |
"export const store = createApropriateStore(rootReducer, applyMiddleware(...middleware));", | |
"export const persistor = persistStore(store);", | |
"", | |
"sagaMiddleware.run(sagas);", | |
"" | |
], | |
"description": "Create configureStore file with Saga" | |
}, | |
"reduxSetup": { | |
"prefix": "reduxSetup", | |
"body": [ | |
"import { combineReducers } from 'redux';", | |
"", | |
"/* Reducers */", | |
"// import navReducer from 'navigation/reducer';", | |
"", | |
"import configureStore from './configureStore';", | |
"// import rootSaga from './sagas';", | |
"", | |
"export default () => {", | |
" const rootReducer = combineReducers({", | |
" // nav: navReducer,", | |
" });", | |
"", | |
" return configureStore(rootReducer, rootSaga);", | |
"};" | |
], | |
"description": "Create Redux Setup file" | |
}, | |
"componentStateless": { | |
"prefix": "componentStateless", | |
"body": [ | |
"/* Core */", | |
"import React from 'react';", | |
"", | |
"/* Presentational */", | |
"import { View } from 'react-native';", | |
"", | |
"// import styles from './styles';", | |
"const ${1:MyComponent} = () => (", | |
" <View />", | |
");", | |
"", | |
"export default ${1:MyComponent};" | |
], | |
"description": "Create react-native stateless component" | |
}, | |
"reduxComponentStateless": { | |
"prefix": "reduxComponentStateless", | |
"body": [ | |
"/* Core */", | |
"import React from 'react';", | |
"", | |
"/* Presentational */", | |
"import { View } from 'react-native';", | |
"", | |
"/* Redux */", | |
"import { connect } from 'react-redux';", | |
"", | |
"// import styles from './styles';", | |
"", | |
"const ${1:MyComponent}} = () => (", | |
" <View />", | |
");", | |
"const mapStateToProps = state => ({", | |
"", | |
"});", | |
"", | |
"const mapDispatchToProps = dispatch => ({", | |
"", | |
"});", | |
"", | |
"export default connect(mapStateToProps, mapDispatchToProps)(${1:MyComponent}});" | |
], | |
"description": "Create react-native stateless Redux component" | |
}, | |
"styles": { | |
"prefix": "styles", | |
"body": [ | |
"import { StyleSheet } from 'react-native';", | |
"", | |
"const styles = StyleSheet.create({", | |
" ${1}", | |
"});", | |
"", | |
"export default styles;", | |
"" | |
], | |
"description": "Create react-native Style file" | |
}, | |
"View Auto": { | |
"prefix": "rnview", | |
"body": [ | |
"<View style={styles.container}>", | |
" ${1}", | |
"</View>", | |
"" | |
], | |
"description": "View auto complete" | |
}, | |
"FlatList Auto": { | |
"prefix": "rnflat", | |
"body": [ | |
"<FlatList", | |
"refreshControl={", | |
" <RefreshControl", | |
" refreshing={this.state.refreshing}", | |
" onRefresh={this.loadRepositories}", | |
" />", | |
"}", | |
"data={this.state.repositories}", | |
"keyExtractor={respository => respository.id}", | |
"renderItem={({ item }) => <Repository repository={item} />}" | |
], | |
"description": "FlatList auto complete" | |
}, | |
"Text Auto": { | |
"prefix": "rntext", | |
"body": [ | |
"<Text style={styles.text}>", | |
" ${1}", | |
"</Text>" | |
], | |
"description": "Text auto complete" | |
}, | |
"ScrollView Auto": { | |
"prefix": "rnscroll", | |
"body": [ | |
"<ScrollView", | |
" style={styles.container}", | |
" contentContainerStyle={styles.contentContainer}", | |
">", | |
" { this.state.loading", | |
" ? <ActivityIndicator size=\"small\" color=\"#999\" style={styles.loading} />", | |
" : this.renderList() }", | |
"</ScrollView>" | |
], | |
"description": "Scroll auto complete" | |
} | |
} | |
// json.json | |
// <==== REMEMBER TO ADD THE CONTENT ABOVE IN THE SPECIFIC FILE ON VSCODE ====> | |
{ | |
/* | |
// Place your snippets for JSON here. Each snippet is defined under a snippet name and has a prefix, body and | |
// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are: | |
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the | |
// same ids are connected. | |
// Example: | |
"Print to console": { | |
"prefix": "log", | |
"body": [ | |
"console.log('$1');", | |
"$2" | |
], | |
"description": "Log output to console" | |
} | |
*/ | |
"moduleResolver": { | |
"prefix": "moduleResolver", | |
"body": [ | |
"{", | |
" \"presets\": [\"react-native\"],", | |
" \"plugins\": [ ", | |
" [", | |
" \"module-resolver\",", | |
" {", | |
" \"cwd\": \"babelrc\",", | |
" \"root\": [\"./src\"],", | |
" \"extensions\": [\".js\", \".ios.js\", \".android.js\"]", | |
" }", | |
" ]", | |
" ]", | |
"}" | |
], | |
"description": "Create Module Resolver config" | |
}, | |
"eslint": { | |
"prefix": "eslint", | |
"body": [ | |
"{", | |
" \"parser\": \"babel-eslint\",", | |
" \"env\": {", | |
" \"browser\": true,", | |
" \"jest\": true", | |
" },", | |
" \"plugins\": [", | |
" \"react-native\",", | |
" \"jsx-a11y\",", | |
" \"import\"", | |
" ],", | |
" \"extends\": [", | |
" \"airbnb\",", | |
" \"plugin:react-native/all\"", | |
" ],", | |
" \"rules\": {", | |
" \"react/jsx-filename-extension\": [\"error\", { \"extensions\": [\".js\", \".jsx\"] }],", | |
" \"global-require\": \"off\",", | |
" \"no-console\": \"off\",", | |
" \"import/prefer-default-export\": \"off\",", | |
" \"no-unused-vars\": [\"error\", {\"argsIgnorePattern\": \"^_\"}]", | |
" },", | |
" \"settings\": {", | |
" \"import/resolver\": {", | |
" \"babel-module\": {}", | |
" }", | |
" },", | |
" \"globals\": {", | |
" \"__DEV__\": true", | |
" }", | |
"}" | |
], | |
"description": "Create eslint file config" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment