Skip to content

Instantly share code, notes, and snippets.

@inspireui
inspireui / .babelrc
Created October 27, 2018 10:03
.babelrc
{
"presets": ["module:metro-react-native-babel-preset"],
"env": {
"production": {
"plugins": [
"transform-remove-console",
["@babel/plugin-proposal-decorators", { "legacy": true }]
]
},
"development": {
@inspireui
inspireui / package.json
Created June 29, 2018 11:10
short import to clean code
/**
* Import with file .js
* example: import { Drawer, SideMenu } from '@components';
*/
{
"name": "@components"
}
@inspireui
inspireui / .babelrc (expo version)
Last active July 2, 2018 07:36
decorators javascript with react native
/**
* Please install https://github.com/expo/babel-preset-expo to use decorators javascript
* And add to .babelrc
*/
{
"presets": ["babel-preset-expo"],
"env": {
"production": {
"plugins": ["transform-remove-console"]
}
@inspireui
inspireui / .prettierrc
Last active June 29, 2018 11:08
inspire ui prettier style
{
"printWidth": 80,
"parser": "babylon",
"useTabs": false,
"tabWidth": 2,
"singleQuote": true,
"jsxBracketSameLine": true,
"arrowParens": "always",
"insertPragma": true,
"semi": false,
@inspireui
inspireui / .eslintrc
Last active June 29, 2018 11:07
inspire ui eslint style
{
"parser": "babel-eslint",
"extends": ["airbnb", "prettier"],
"parserOptions": {
"ecmaFeatures": {
"experimentalObjectRestSpread": true,
"jsx": true,
"modules": true
},
"ecmaVersion": 7,
@inspireui
inspireui / ..React native Performance tuning
Last active June 29, 2018 11:08
React Native performance
Author: inspireUI
Website: inspireui.com
- Should be use PureComponent to avoid re-render many times --> https://reactjs.org/docs/react-api.html#reactpurecomponent
- Seperate Container file and Component file --> https://medium.com/@dan_abramov/smart-and-dumb-components-7ca2f9a7c7d0
- Avoid use .bind when handle function --> https://stackoverflow.com/a/32192892/6622971
- Don’t use arrow functions in your render methods --> onPress={(e) => this.handlePress(e)} --> only use when need pass params to handle, or
export default ({deleteItem, item}) => {
const _onDeleteTap(){
deleteItem(item.id)
watchman watch-del-all && rm -rf $TMPDIR/react-* && rm -rf node_modules/ && npm cache clean && npm install && npm start -- --reset-cache