Skip to content

Instantly share code, notes, and snippets.

View ericrav's full-sized avatar

Eric Rabinowitz ericrav

View GitHub Profile
@ericrav
ericrav / index.html
Created January 12, 2024 14:20
🔴🟡🟢
<head>
<title>🔴</title>
</head>
<script>
const emojis = ['🔴', '🟡', '🟢'];
let val = emojis[0];
setInterval(() => {
for (let i = 0; i < val.length; i += 2) {
if (Math.random() < 0.25) {
const x = (emojis.indexOf(val.slice(i, i + 2)) + 1) % emojis.length;
@ericrav
ericrav / @testing-library-react-hooks-testHook.ts
Last active March 4, 2022 19:02
@testing-library/react-hooks renderHook wrapper for calling a hook in tests the same as in components
import { renderHook, RenderResult } from '@testing-library/react-hooks';
export function testHook<P extends any[], T>(hook: (...args: P) => T) {
let firstCall = true;
let rerenderHook: (props: P) => void;
let hookResult: RenderResult<T>;
const useHook = (...args: P) => {
if (firstCall) {
const { result, rerender } = renderHook(

Keybase proof

I hereby claim:

  • I am ericrav on github.
  • I am ericrav (https://keybase.io/ericrav) on keybase.
  • I have a public key ASCgZYL3Lzbua5IfclF7mdf3YOnRii7ABBHJUjeN3QcIpgo

To claim this, I am signing this object: