Skip to content

Instantly share code, notes, and snippets.

@hmans hmans/

Last active Apr 19, 2017
What would you like to do?
Inferno.js memoization decorator function using NO_OP
memoize = require './memoize'
# By using memoize, the following functional component will only update
# when the props passed into it have changed. Please note that this assumes
# that the actual prop values are immutable objects, since we don't perform
# any deep equality checks.
logPanel = memoize ({log}) ->
h '#log-panel', [
for line in log
h logLine, {line}
{ NO_OP } = require 'inferno'
equals = require 'shallow-equals'
module.exports = (fn) ->
oldProps = null
(props) ->
if equals oldProps, props
oldProps = props
fn props
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.