Skip to content

Instantly share code, notes, and snippets.

@Rendalf
Rendalf / container.js
Created December 21, 2018 20:32
MapStateToProps function factory example
const createMemoizedFooSelector = (state, ownProps) => {
return memoizeLast((state, ownProps) => ({
a: state.as.filter((a) => a.id === ownProps.id),
b: state.bs.byId[ownProps.id],
}))
}
const createMapStateToProps = () => {
const selectFoo = createMemoizedFooSelector()
@Rendalf
Rendalf / preact-fails-ref.jsx
Last active March 19, 2018 08:18
Preact fails ref
// failed ref
const MyShinyComponent = ({ isFooShown }) => (
<div className='wrapper'>
{ isFooShown && (
<div className='foo'>Foo</div>
)}
<div
className='bar'
ref={ someRefFunc }
>
@Rendalf
Rendalf / index.html
Created January 14, 2017 09:01 — forked from ga2mer/index.html
Untitled benchmark (http://jsbench.github.io/#9bc10bb16a6813a84bc4ed57742ded63) #jsbench #jsperf
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>Untitled benchmark</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script>
<script src="./suite.js"></script>
</head>
<body>
<h1>Open the console to view the results</h1>