Skip to content

Instantly share code, notes, and snippets.

View JoaoTMDias's full-sized avatar

João Dias JoaoTMDias

View GitHub Profile
@JoaoTMDias
JoaoTMDias / use-event.ts
Last active April 20, 2023 11:46
React hook to use as addEventListener in React's functional components
import { useEffect } from "react";
/**
* This replaces the need for using window.addEventListener() when using react hooks.
* You use it in exactly the same way as window.addEventListener().
*
* @example
* useEvent(event, listener, useCapture)
*
* @export
@JoaoTMDias
JoaoTMDias / sc-media-queries.helper.tsx
Created February 18, 2019 11:44
Styled Components Media Queries Helepr
import { css } from 'styled-components'
/**
* For the specified media query, returns a tag function that can be used to
* automatically wrap the tagged template literal in its media query.
*
* @param {string} query The string or template literal containing the media
* query features.
*/