diff options
author | Maximilian Hils <git@maximilianhils.com> | 2016-07-21 03:00:10 -0700 |
---|---|---|
committer | Maximilian Hils <git@maximilianhils.com> | 2016-07-21 03:00:10 -0700 |
commit | 3d6f714b5d768b7ce24091f03a0e05e47a534271 (patch) | |
tree | 6dabae34ec7a4a50a7508ac855692e472d63215c /web/src/js/utils.js | |
parent | 6ffeaaebed0ac248b5ba1f60c6add44eb6e98004 (diff) | |
download | mitmproxy-3d6f714b5d768b7ce24091f03a0e05e47a534271.tar.gz mitmproxy-3d6f714b5d768b7ce24091f03a0e05e47a534271.tar.bz2 mitmproxy-3d6f714b5d768b7ce24091f03a0e05e47a534271.zip |
web: perf++
Diffstat (limited to 'web/src/js/utils.js')
-rw-r--r-- | web/src/js/utils.js | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/web/src/js/utils.js b/web/src/js/utils.js index eceda195..eecacfbb 100644 --- a/web/src/js/utils.js +++ b/web/src/js/utils.js @@ -1,7 +1,9 @@ -import _ from "lodash"; +import _ from 'lodash' +import React from 'react' +import shallowEqual from 'shallowequal' window._ = _; -window.React = require("react"); +window.React = React; export var Key = { UP: 38, @@ -105,3 +107,16 @@ fetchApi.put = (url, json, options) => fetchApi( ...options } ) + +export const pure = renderFn => class extends React.Component { + static displayName = renderFn.name + + shouldComponentUpdate(nextProps) { + console.log(!shallowEqual(this.props, nextProps)) + return !shallowEqual(this.props, nextProps) + } + + render() { + return renderFn(this.props) + } +} |