syanbo / blog Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
@ReactMethod(isBlockingSynchronousMethod = true)
RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD
"dependencies": {
"syan-components": "file:./src/components"
}
{
"name": "syan-components",
"version": "1.0.0"
}
import { BasePureComponent } from 'syan-components';
[
'babel-plugin-root-import',
{
paths: [
{
rootPathPrefix: '~',
rootPathSuffix: 'js',
},
],
},
],
{
"compilerOptions": {
"jsx": "react-native",
"allowSyntheticDefaultImports": false,
"experimentalDecorators": true,
"baseUrl": ".",
"paths": {
"~/*": ["js/*"]
}
},
"include": ["js/**/*"],
"exclude": ["node_modules"]
}
使用react-native-git-upgrade命令进行升级
执行完成原生代码重置到了初始化
所有第三方需要重新link配置
View.PropTypes.style
需要换成 import { ViewPropTypes } from 'react-native';
ViewPropTypes.style
import React, { PropTypes } from 'react';
需要把PropTypes换到单独的npm包 prop-type
'index.android.bundle'. Make sure your bundle is packaged correctly or you're running a packager server.
项目目录运行 react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res
建议 init 一个同样包名的项目把android或者ios文件进行替换
这样能更快帮你解决遇到的奇怪问题
ESLint 可以对你代码进行检查
Prettier 代码格式化工具,能够统一你或者团队的代码风格(酷爱)
Pre-commit Hook 在代码进行Git提交的时候进行格式化,如果有错误并终止push
yarn add -D babel-eslint eslint eslint-config-prettier eslint-config-react-app eslint-plugin-import eslint-plugin-jsx-a11y eslint-plugin-flowtype eslint-plugin-prettier eslint-plugin-react husky lint-staged pretty-quick prettier
.eslintrc
文件{
"extends": ["react-app", "plugin:prettier/recommended"],
"rules": {
"no-undef": 0,
"no-useless-constructor": 0
}
}
具体的rules规则可以根据各自喜好添加
"scripts": {
"precommit": "pretty-quick --staged"
}
package.json
中添加Prettier配置根据自己喜好 "prettier": {
"singleQuote": true
}
你可以执行命令 prettier --write src/**/*.js
src对应你的文件夹
Alt-Shift-Ctrl-P
具体在设置搜索Prettier可以找到Preferences | Tools | File Watchers and click + to add a new watcher.
然后进行快捷键绑定 传送到官网"editor.formatOnSave": true,
"javascript.format.enable": false,
"prettier.eslintIntegration": true
react-native-bundle-visualizer
babel-plugin-import
[
'import',
{
libraryDirectory: 'components',
libraryName: 'teaset',
camel2DashComponentName: false,
customName: (name) => {
if (name === 'TopView') {
return 'teaset/components/Overlay/TopView';
} else if (name === 'Theme') {
return 'teaset/themes/Theme';
} else {
return `teaset/components/${name}/${name}`;
}
},
},
],
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.