Skip to content

dutzi/use-on

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

use-on

This repo demonstrates some React weirdness.

I was trying to implement a hook that allows me to do the following:

useOn()
  .who(window)
  .when('resize')
  .what(() => {
    console.log('resize!');
  });

Don't ask why. I just thought it was pretty.

Turns out you can, but using the approach I came up with, it only works in production.

Can you tell why?

Usage

On your machine

Clone the repo, then:

npm i       # yarn
npm start   # yarn start

Then follow the instructions you see on the page, you will see my approach failing.

To see it running fine, you'll need to:

npm run start:prod   # yarn start:prod

On CodeSandbox

Visit this repo's CodeSandbox, to see it failing (as you did if you ran it on your machine).

On Vercel

Visit this repo's Vercel deployment, to see it running fine.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published