- Animated values are now instances of the
SpringValue
class, which gives users access to an imperative API for updating a single animated value. - The
reset
andimmediate
props can now be a key or array of keys, instead of only a function or boolean. - The
next
function passed to asyncto
prop can now be passed anyuseSpring
props, instead of onlyto
values. - The
useSpring
hook now supports a deps array, for updating an animation only when certain values changed. - The
useTransition
hook was rewritten from scratch. (see #809) - The
useTransition
hook now has aref
prop. - The new
cancel
prop stops the current animation and prevents future animations. It can be a boolean, a function, a key, or an array of keys. - Delayed updates can be cancelled by the
cancel
prop orstop
method.
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 roundToStep(n: number, step: number) { | |
n = Math.round(n / step) * step | |
// Determine the number of decimals to round. | |
let p = 0 | |
if (n % 1) { | |
const s = String(n) | |
p = s.length - s.indexOf('.') - 1 | |
} |
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 { createHook } from './createHook' | |
class App { | |
count = 0 | |
increaseCount() { | |
this.count++ | |
} | |
decreaseCount() { | |
this.count-- | |
} |
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 {useSubscriber} from 'react' | |
const MyComponent = (props) => { | |
// Get the current value of an observable | |
const value = props.value.get() | |
// Subscribe to the observable in the render phase | |
useSubscriber(forceUpdate => { | |
// This code runs immediately, instead of acting like "useEffect" | |
const unsub = props.value.subscribe(() => { |
There are two types of hotkeys: global and local.
- Global hotkeys work even when the application is inactive.
- Local hotkeys only work when the application is active.
The implementation for global hotkeys would be adapted from davedelong/DDHotKey.
The implementation for local hotkeys would use the RCTKeyCommands
class that already exists.
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 interface Lens<T> { | |
(): T | |
(newValue: T): void | |
} | |
export function bind<T>(get: () => T, set: (newValue: T) => void): Lens<T> | |
export function bind<T, U>(target: Map<T, U>, key: T): Lens<U> | |
export function bind<T extends object, P extends keyof T>( | |
target: T, | |
key: P |
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
#include <os/log.h> | |
RCTLogFunction RCTDefaultLogFunction = ^( | |
RCTLogLevel level, | |
__unused RCTLogSource source, | |
NSString *fileName, | |
NSNumber *lineNumber, | |
NSString *message | |
) | |
{ |
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 * as React from 'react' | |
import { UserView } from './components/user' | |
import gql from 'vana/gql' | |
// Create a data store with vana.useGraphQL | |
const data = gql.create({ | |
...options, | |
queries: { | |
users: gql`...`, | |
} |
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 runTopological = <T>( | |
packages: PackageJson[], | |
action: (pkg: PackageJson) => Promise<T> | |
): Promise<T[]> => { | |
const promises: Promise<T>[] = [] | |
const run = (pkg: PackageJson, i: number) => | |
promises[i] || | |
(promises[i] = Promise.all( | |
Object.keys(pkg.dependencies || {}).map(name => { | |
const i = packages.findIndex(pkg => pkg.name === name) |
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
// Convert "translate(10px) rotate(0)" into ["translate", "rotate"] | |
// This helps interpolate strings of different arity. | |
const keyRegex = /(?:^| )([\w-]+)\(([^ ,]+(?:(?:,[ ]*|[ ]+)[^ ,)]+)*)\)/g | |
/** | |
* Create a specialized interpolator for strings like: | |
* | |
* "translate(...) rotate(...)" | |
*/ |