Skip to content

Instantly share code, notes, and snippets.

View facuescobar's full-sized avatar

Facu Escobar facuescobar

View GitHub Profile
@gchumillas
gchumillas / AppText.tsx
Last active November 14, 2023 20:12
React Native: how to extend Text component (the "hook" and the "class" way).
import React from 'react'
import { Text, TextProps } from 'react-native'
// The "hook" way.
// The `React.PropsWithChildren` type adds the `children` property to the `TextProps` type.
const AppText1 = ({ children, style, ...rest }: React.PropsWithChildren<TextProps>) => (
<Text style={[{ fontFamily: 'monospace' }, style]} {...rest}>
{children}
</Text>
)
@jarretmoses
jarretmoses / React Native Clear Cache
Last active June 3, 2024 05:22
Clearing the Cache of your React Native Project
RN < 0.50 - watchman watch-del-all && rm -rf $TMPDIR/react-* && rm -rf node_modules/ && npm cache clean && npm install && npm start -- --reset-cache
RN >= 0.50 - watchman watch-del-all && rm -rf $TMPDIR/react-native-packager-cache-* && rm -rf $TMPDIR/metro-bundler-cache-* && rm -rf node_modules/ && npm cache clean && npm install && npm start -- --reset-cache
RN >= 0.63 - watchman watch-del-all && rm -rf node_modules && npm install && rm -rf /tmp/metro-* && npm run start --reset-cache
npm >= 5 - watchman watch-del-all && rm -rf $TMPDIR/react-* && rm -rf node_modules/ && npm cache verify && npm install && npm start -- --reset-cache
Windows - del %appdata%\Temp\react-native-* & cd android & gradlew clean & cd .. & del node_modules/ & npm cache clean --force & npm install & npm start -- --reset-cache
@psebborn
psebborn / countCSSRules.js
Last active April 25, 2023 11:43
Count the number of rules and selectors for CSS files on the page. Flags up the >4096 threshold that confuses IE
function countCSSRules() {
var results = '',
log = '';
if (!document.styleSheets) {
return;
}
for (var i = 0; i < document.styleSheets.length; i++) {
countSheet(document.styleSheets[i]);
}
function countSheet(sheet) {