File tree Expand file tree Collapse file tree 1 file changed +14
-10
lines changed Expand file tree Collapse file tree 1 file changed +14
-10
lines changed Original file line number Diff line number Diff line change @@ -108,8 +108,8 @@ class Menu extends React.Component<MenuProps> {
108108 this . updateMiniStore ( ) ;
109109 }
110110
111- componentDidUpdate ( ) {
112- this . updateMiniStore ( ) ;
111+ componentDidUpdate ( prevProps : MenuProps ) {
112+ this . updateMiniStore ( prevProps ) ;
113113 }
114114
115115 onSelect = ( selectInfo : SelectInfo ) => {
@@ -215,16 +215,20 @@ class Menu extends React.Component<MenuProps> {
215215 this . innerMenu = node ;
216216 } ;
217217
218- updateMiniStore ( ) {
218+ updateMiniStore ( prevProps ?: MenuProps ) {
219219 if ( 'selectedKeys' in this . props ) {
220- this . store . setState ( {
221- selectedKeys : this . props . selectedKeys || [ ] ,
222- } ) ;
220+ if ( ! prevProps || this . props . selectedKeys !== prevProps . selectedKeys ) {
221+ this . store . setState ( {
222+ selectedKeys : this . props . selectedKeys || [ ] ,
223+ } ) ;
224+ }
223225 }
224- if ( 'openKeys' in this . props ) {
225- this . store . setState ( {
226- openKeys : this . props . openKeys || [ ] ,
227- } ) ;
226+ if ( 'openKeys' in this . props && this . props . openKeys . length ) {
227+ if ( ! prevProps || this . props . openKeys !== prevProps . openKeys ) {
228+ this . store . setState ( {
229+ openKeys : this . props . openKeys || [ ] ,
230+ } ) ;
231+ }
228232 }
229233 }
230234
You can’t perform that action at this time.
0 commit comments