Skip to content

Instantly share code, notes, and snippets.

import React, { useContext, useEffect, useState, useCallback } from 'react';
import { TouchableWithoutFeedbackProps } from 'react-native';
import useDelayedState from './useDelayedState';
const FocusChangeContext = React.createContext<(isFocused: boolean, instant?: boolean) => void>(
() => undefined
);
const HasFocusContext = React.createContext<boolean>(false);
import { useState, useCallback } from 'react'
import { LayoutChangeEvent } from 'react-native'
interface Measurement {
width: number
height: number
}
type OnLayoutCallback = (event: LayoutChangeEvent) => void
@Krisztiaan
Krisztiaan / @types+react-native+0.62.14.patch
Last active August 26, 2020 20:54
Simple react-native-tvos typescript support. Use with `patch-package`.
diff --git a/node_modules/@types/react-native/index.d.ts b/node_modules/@types/react-native/index.d.ts
index dba6a80..114a383 100644
--- a/node_modules/@types/react-native/index.d.ts
+++ b/node_modules/@types/react-native/index.d.ts
@@ -63,6 +63,41 @@
import * as React from 'react';
+export const TVMenuControl: {
+ enableTVMenuKey(): void;
@Krisztiaan
Krisztiaan / index.d.ts
Created September 9, 2020 20:27
react-native-tvos@0.62.2-1 typescript typing extension
import '@types/react-native';
import React from 'react';
import { ViewProps } from 'react-native';
declare module 'react-native' {
export const TVMenuControl: {
enableTVMenuKey(): void;
disableTVMenuKey(): void;
};
import { useState, useEffect } from 'react'
export default function useDebouncedState<T>(value: T, delay: number) {
const [debouncedValue, setDebouncedValue] = useState<T>(value)
useEffect(() => {
const handler = setTimeout(() => setDebouncedValue(value), delay)
return () => clearTimeout(handler)
}, [value, delay, setDebouncedValue])
@Krisztiaan
Krisztiaan / package.json
Created March 12, 2021 08:56
Simple debounce hook
{
"name": "use-debounce",
"version": "1.0.0",
"main": "useDebounce.ts"
}
@Krisztiaan
Krisztiaan / package.json
Last active April 1, 2021 13:57
Simple hook to use Fuse.js
{
"name": "use-fuse",
"version": "1.0.1",
"main": "useFuse.ts"
}
type AnyValue =
| { [key: string]: AnyValue }
| { [key: number]: AnyValue }
| AnyValue[]
| string
| number
| boolean
| null
| undefined
| symbol
import React, { useRef, useImperativeHandle } from 'react';
import type { HostComponent } from 'react-native';
import {
NativeModules,
findNodeHandle,
Platform,
UIManager,
requireNativeComponent,
} from 'react-native';
@Krisztiaan
Krisztiaan / clean_workflows.sh
Created February 13, 2022 14:02
Delete all workflow runs from disabled actions, so GitHub will not show them in actions anymore.
#!/bin/bash
if ! command -v gh &>/dev/null; then
echo "The GitHub CLI <gh> could not be found."
read -p "Do you want to install it? " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
echo "Installing GitHub CLI..."
if ! command -v brew &>/dev/null; then
echo "The <brew> command could not be found."