From 742643c296fca7b5907ba08adf0d0d9bc2b925b0 Mon Sep 17 00:00:00 2001 From: solarjoker Date: Fri, 25 Oct 2019 18:20:33 +0800 Subject: [PATCH] fix: checkbox list do not change but rerender --- components/checkbox/CheckBox.js | 7 +++++++ package.json | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/components/checkbox/CheckBox.js b/components/checkbox/CheckBox.js index 24dbe9863..8efbed3b6 100644 --- a/components/checkbox/CheckBox.js +++ b/components/checkbox/CheckBox.js @@ -2,6 +2,7 @@ import React, { Component } from 'react' import PropTypes from 'prop-types' import Base from './Base' import MultipleCheckboxsOpera from './common' +import isEqual from 'lodash/isEqual' class CheckBox extends Component { static _type = 'CheckBox' static propTypes = { @@ -32,6 +33,12 @@ class CheckBox extends Component { componentWillUnmount () { MultipleCheckboxsOpera.remove(this.props.name || this.props.all) } + shouldComponentUpdate (nextProps, nextState) { + if (this.props.list && isEqual(this.props.list, nextProps.list)) { + return false + } + return true + } renderCheckBoxGroup (list) { return
{ diff --git a/package.json b/package.json index a68aa4874..48469f4c2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@hi-ui/hiui", - "version": "1.5.11", + "version": "1.5.12", "description": "HIUI for React", "scripts": { "test": "node_modules/.bin/standard && node_modules/.bin/stylelint --config .stylelintrc 'components/**/*.scss'",