Skip to content

Commit

Permalink
fix(barcode/qrcode): all props should trigger hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
Miaonster committed Dec 17, 2019
1 parent 317acf2 commit 272417e
Show file tree
Hide file tree
Showing 9 changed files with 3,427 additions and 121 deletions.
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dist/*
.temp/*
15 changes: 12 additions & 3 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,17 @@
"extends": ["taro"],
"rules": {
"no-unused-vars": ["error", { "varsIgnorePattern": "Taro" }],
"react/jsx-filename-extension": [1, { "extensions": [".js", ".jsx", ".tsx"] }],
"react/jsx-filename-extension": [
1,
{ "extensions": [".js", ".jsx", ".tsx"] }
],
"no-shadow": 0
},
"parser": "babel-eslint"
}
"globals": {
"describe": true,
"beforeEach": true,
"it": true,
"expect": true
},
"parser": "babel-eslint"
}
8 changes: 4 additions & 4 deletions config/dev.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// eslint-disable-next-line import/no-commonjs
module.exports = {
env: {
NODE_ENV: '"development"'
},
defineConstants: {
NODE_ENV: '"development"',
},
defineConstants: {},
weapp: {},
h5: {}
h5: {},
}
8 changes: 4 additions & 4 deletions config/prod.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// eslint-disable-next-line import/no-commonjs
module.exports = {
env: {
NODE_ENV: '"production"'
},
defineConstants: {
NODE_ENV: '"production"',
},
defineConstants: {},
weapp: {},
h5: {
/**
Expand All @@ -14,5 +14,5 @@ module.exports = {
* .use(require('webpack-bundle-analyzer').BundleAnalyzerPlugin, [])
* }
*/
}
},
}
82 changes: 54 additions & 28 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,62 +1,88 @@
{
"name": "taro-code",
"version": "2.0.3",
"version": "2.0.4",
"description": "Taro.js barcode & qrcode",
"homepage": "https://github.com/miaonster/taro-code",
"license": "MIT",
"author": "miaonster <[email protected]>",
"files": [
"dist"
],
"type": "module",
"main": "dist/index.js",
"scripts": {
"build": "export TARO_BUILD_TYPE=ui && taro build --ui",
"build:weapp": "taro build --type weapp",
"build:swan": "taro build --type swan",
"build:alipay": "taro build --type alipay",
"build:tt": "taro build --type tt",
"build:h5": "taro build --type h5",
"build:rn": "taro build --type rn",
"dev:weapp": "npm run build:weapp -- --watch",
"dev:swan": "npm run build:swan -- --watch",
"dev:alipay": "npm run build:alipay -- --watch",
"dev:tt": "npm run build:tt -- --watch",
"dev:h5": "npm run build:h5 -- --watch",
"dev:rn": "npm run build:rn -- --watch",
"update:project": "taro update project"
"dev:swan": "npm run build:swan -- --watch",
"dev:tt": "npm run build:tt -- --watch",
"dev:weapp": "npm run build:weapp -- --watch",
"update:project": "taro update project",
"test": "jest",
"lint": "eslint ."
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"lint-staged": {
"*.js": [
"eslint --fix",
"git add"
]
},
"config": {
"commitizen": {
"path": "./node_modules/cz-conventional-changelog"
}
},
"author": "Miaonster <[email protected]>",
"license": "MIT",
"files": [
"dist"
],
"main": "dist/index.js",
"homepage": "https://github.com/Miaonster/taro-code",
"dependencies": {
"wx-base64-qrcode": "^1.0.4"
},
"devDependencies": {
"@babel/core": "^7.7.5",
"@babel/plugin-proposal-class-properties": "^7.7.4",
"@babel/plugin-proposal-object-rest-spread": "^7.7.4",
"@babel/plugin-transform-react-jsx": "^7.7.4",
"@babel/preset-env": "^7.7.6",
"@tarojs/cli": "1.3.29",
"@tarojs/components": "1.3.29",
"@tarojs/plugin-babel": "1.3.29",
"@tarojs/plugin-csso": "1.3.29",
"@tarojs/plugin-uglifyjs": "1.3.29",
"@tarojs/router": "1.3.29",
"@tarojs/taro": "1.3.29",
"@tarojs/taro-alipay": "1.3.29",
"@tarojs/taro-h5": "1.3.29",
"@tarojs/taro-swan": "1.3.29",
"@tarojs/taro-tt": "1.3.29",
"@tarojs/taro-weapp": "1.3.29",
"nerv-devtools": "^1.5.6",
"nervjs": "^1.5.6",
"wx-base64-qrcode": "^1.0.4"
},
"devDependencies": {
"@tarojs/cli": "1.3.29",
"@tarojs/plugin-babel": "1.3.29",
"@tarojs/plugin-csso": "1.3.29",
"@tarojs/plugin-uglifyjs": "1.3.29",
"@tarojs/webpack-runner": "1.3.29",
"@types/react": "^16.4.6",
"@types/webpack-env": "^1.13.6",
"babel-core": "^7.0.0-bridge.0",
"babel-eslint": "^8.2.3",
"babel-jest": "^24.9.0",
"babel-plugin-transform-class-properties": "^6.24.1",
"babel-plugin-transform-decorators-legacy": "^1.3.4",
"babel-plugin-transform-jsx-stylesheet": "^0.6.5",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"babel-preset-env": "^1.6.1",
"cz-conventional-changelog": "^3.0.2",
"eslint": "^4.19.1",
"eslint-config-taro": "1.3.29",
"eslint-plugin-import": "^2.12.0",
"eslint-plugin-react": "^7.8.2",
"eslint-plugin-react-hooks": "^2.3.0",
"eslint-plugin-taro": "1.3.29"
"eslint-plugin-taro": "1.3.29",
"husky": ">=1",
"jest": "^24.9.0",
"lint-staged": ">=8",
"miniprogram-automator": "^0.8.0",
"nerv-devtools": "^1.5.6",
"nervjs": "^1.5.6",
"sinon": "^7.5.0"
}
}
2 changes: 1 addition & 1 deletion src/components/Barcode/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function BarCode({ text, scale, width, height }) {
} else {
setImage('')
}
}, [text])
}, [text, scale])

const widthString = width ? width + 'px' : ''
const heightString = height ? height + 'px' : ''
Expand Down
2 changes: 1 addition & 1 deletion src/components/Qrcode/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function QRCode({ text, size, scale, typeNumber, errorCorrectLevel }) {
} else {
setImage('')
}
}, [text])
}, [text, scale, size, errorCorrectLevel, typeNumber])

const style = { width: size + 'px', height: size + 'px' }
return <Image style={style} src={image} />
Expand Down
8 changes: 4 additions & 4 deletions src/pages/index/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@ import QRCode from '../../components/QRCode'
import './index.css'

export default class Index extends Component {
config = {
navigationBarTitleText: '首页',
}

state = {
text: 'hello',
}
Expand All @@ -21,6 +17,10 @@ export default class Index extends Component {
}, 1000)
}

config = {
navigationBarTitleText: '首页',
}

render() {
return (
<View className='index'>
Expand Down
Loading

0 comments on commit 272417e

Please sign in to comment.