This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const LazyScrollView = forwardRef(function LazyScrollView( | |
props: LazyScrollViewProps, | |
ref: ForwardedRef<FlashList<unknown[]>>, | |
): JSX.Element { | |
const {children, estimatedScrollViewSize, estimatedItemSize} = | |
props; | |
const data = isArray(children) ? children : Children.toArray(children); | |
// No specific reason for 2000, just a big number. Roughly 2x the screen size |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useCallback } from "react"; | |
import { useQueryClient } from "@tanstack/react-query"; | |
export default function useOptimisticUpdate() { | |
const queryClient = useQueryClient(); | |
return useCallback( | |
async (queryKey, updater) => { | |
await queryClient.cancelQueries({ queryKey }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Breakpoints from './Breakpoints'; | |
import { css, cx } from '@emotion/css'; | |
import { HTMLAttributes, forwardRef } from 'react'; | |
export type StackProps = { | |
adaptive?: true; | |
alignCenter?: true; | |
center?: true; | |
children?: React.ReactNode; | |
className?: string; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { FlashList, FlashListProps } from "@shopify/flash-list"; | |
import React, { forwardRef, ReactElement } from "react"; | |
type ListProps<T> = Omit<FlashListProps<T>, "children"> & { as?: "list" }; | |
type ScrollViewProps<T> = Omit< | |
FlashListProps<T>, | |
"children" | "data" | "renderItem" | |
> & { | |
as?: "scroll-view"; | |
children: React.ReactNode | React.ReactNode[]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"explorer.fileNesting.enabled": true, | |
"explorer.fileNesting.patterns": { | |
"*.js": "${capture}.js.map, ${capture}.d.ts, ${capture}.d.ts.map", | |
"*.ts": "$(capture).test.ts, $(capture).test.tsx, $(capture).test.node.ts, $(capture).test.node.tsx, $(capture).test.native.ts, $(capture).test.native.tsx, $(capture).test.ios.ts, $(capture).test.ios.tsx, $(capture).test.web.ts, $(capture).test.web.tsx, $(capture).test.android.ts, $(capture).test.android.tsx, ${capture}.native.tsx, ${capture}.ios.tsx, ${capture}.android.tsx, ${capture}.web.tsx, ${capture}.native.ts, ${capture}.ios.ts, ${capture}.android.ts, ${capture}.web.ts, ${capture}.native.js, ${capture}.ios.js, ${capture}.android.js, ${capture}.web.js, ${capture}.native.jsx, ${capture}.ios.jsx, ${capture}.android.jsx, ${capture}.web.jsx", | |
"*.tsx": "$(capture).test.ts, $(capture).test.tsx, $(capture).test.node.ts, $(capture).test.node.tsx, $(capture).test.native.ts, $(capture).test.native.tsx, $(capture).test.ios.ts, $(capture).test.ios.tsx, $(captur |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Favorite({ | |
postId = null, | |
isLiked: _isLiked = false, | |
numberOfLikes: _numberOfLikes = 0, | |
}) { | |
const [isLiked, setIsLiked] = React.useState(_isLiked); | |
const [numberOfLikes, setNumberOfLikes] = React.useState(_numberOfLikes ?? 0); | |
const likeDebounceRef = React.useRef(); | |
const lastIsLikedStateRef = React.useRef(_isLiked); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
import SwiftUI | |
class ViewController: UIViewController { | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
let box = UIView() | |
box.frame = CGRect(x: (view.bounds.width / 2.0) - 100.0, y: 0.0, width: 100.0, height: 100.0) | |
box.backgroundColor = .systemGreen |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Dimensions } from 'react-native'; | |
const { height: screenHeight, width: screenWidth } = Dimensions.get('window'); | |
const EACH_HEIGHT_UNIT = screenHeight / 100 | |
const EACH_WIDTH_UNIT = screenWidth / 100 | |
/** | |
* device height percentage | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
import AVFoundation | |
class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource { | |
let tableView = UITableView(frame: .zero, style: .plain) | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
tableView.register(PlayerTableViewCell.self, forCellReuseIdentifier: "PlayerCell") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
class ViewController: UIViewController { | |
let textViewWrapper = TextViewWrapper() | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
// The problem view! I want to add this one to my set of Auto Layout constraints, | |
// even though it's not using Auto Layout internally. |
NewerOlder