mirror of
				https://github.com/reduxjs/redux-devtools.git
				synced 2025-10-31 16:07:45 +03:00 
			
		
		
		
	deep equal on shouldComponentUpdate
This commit is contained in:
		
							parent
							
								
									0055b0263d
								
							
						
					
					
						commit
						37a8fc190f
					
				|  | @ -1,3 +1,5 @@ | |||
| import deepEqual from '../../../utils/deepEqual'; | ||||
| 
 | ||||
| export default { | ||||
|   handleClick(e) { | ||||
|     e.stopPropagation(); | ||||
|  | @ -11,5 +13,9 @@ export default { | |||
|     this.renderedChildren = []; | ||||
|     this.itemString = false; | ||||
|     this.needsChildNodes = true; | ||||
|   }, | ||||
| 
 | ||||
|   shouldComponentUpdate(nextProps, nextState) { | ||||
|     return !deepEqual(this.state, nextState) || !deepEqual(this.props, nextProps); | ||||
|   } | ||||
| }; | ||||
|  |  | |||
							
								
								
									
										22
									
								
								src/utils/deepEqual.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								src/utils/deepEqual.js
									
									
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,22 @@ | |||
| const deepEqual = function (x, y) { | ||||
|   if ((typeof x == "object" && x != null) && (typeof y == "object" && y != null)) { | ||||
|     if (Object.keys(x).length != Object.keys(y).length) { | ||||
|       return false; | ||||
|     } | ||||
|     for (var prop in x) { | ||||
|       if (y.hasOwnProperty(prop)) { | ||||
|         if (! deepEqual(x[prop], y[prop])) { | ||||
|           return false; | ||||
|         } | ||||
|       } else { | ||||
|         return false; | ||||
|       } | ||||
|     } | ||||
|     return true; | ||||
|   } else if (x !== y){ | ||||
|     return false; | ||||
|   } | ||||
|   return true; | ||||
| } | ||||
| 
 | ||||
| export default deepEqual; | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user