Skip to content

Instantly share code, notes, and snippets.

View felpin's full-sized avatar
💭
Felipe ❤️ JavaScript

Felipe de Alencar Pinheiro felpin

💭
Felipe ❤️ JavaScript
  • AvantStay
  • São José, SC - Brazil
View GitHub Profile
@felpin
felpin / ComponentWithInternalRef.tsx
Created September 6, 2023 22:24
Component with an internal ref that syncs with a ref received br arguments
import {forwardRef, ForwardRefRenderFunction, MutableRefObject, useRef} from 'react'
const _ComponentWithInternalRef: ForwardRefRenderFunction<HTMLDivElement> = (props, ref) => {
const internalRef: MutableRefObject<HTMLDivElement | null> = useRef(null)
const internalCallbackRef = (element: HTMLDivElement | null) => {
internalRef.current = element
if (!ref) return
<!-- SRC: https://csswizardry.com/2020/05/the-fastest-google-fonts/ -->
<!--
- 1. Preemptively warm up the fonts’ origin.
-
- 2. Initiate a high-priority, asynchronous fetch for the CSS file. Works in
- most modern browsers.
-
- 3. Initiate a low-priority, asynchronous fetch that gets applied to the page
- only after it’s arrived. Works in all browsers with JavaScript enabled.
-
@felpin
felpin / react-performance-checklist
Created October 11, 2018 12:31
A checklist regarding common React performance issues
============================================================
REACT PERFORMANCE CHECKLIST
============================================================
1. Identify wasted renders
2. Extract frequently updated regions into isolated components
3. Use pure components when appropriate
4. Avoid passing new objects as props
5. Use the production build
6. Employ code splitting