Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let oldProps = null;
- function shallowCompare (props){
- if(props !== oldProps) console.log(props);
- oldProps = props;
- }
- const mary = { name: "mary", age: 20 };
- const john = { name: "john", age: 30 };
- shallowCompare(mary) // prints -> { name: "mary", age: 20 }
- shallowCompare(john) // prints -> { name: "john", age: 30 }
- john.age = 31;
- shallowCompare(john) // will not print!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement