- Shim React and React Native - Move src/components to lib/components - Exposed lib/components to `unscoped.components` - scipts/build: Properly set footer sourceURL - plugins/developer-settings: Debounce searching in Asset Browser - plugins/settings: Debounce searching in Plugins
31 lines
829 B
TypeScript
31 lines
829 B
TypeScript
// @revenge-mod/storage depends on this file, and it is imported way too early, so we can't import our shim
|
|
import { React } from '@revenge-mod/react'
|
|
import { findInTree } from './trees'
|
|
import type { ReactNode } from 'react'
|
|
import type { SearchFilter } from './trees'
|
|
|
|
export function useIsFirstRender() {
|
|
let firstRender = false
|
|
|
|
React.useEffect(() => {
|
|
firstRender = true
|
|
}, [])
|
|
|
|
return firstRender
|
|
}
|
|
|
|
export function useReRender() {
|
|
const [, forceUpdate] = React.useReducer(x => ~x, 0)
|
|
return forceUpdate
|
|
}
|
|
|
|
const ReactFiberWalkable = new Set(['props', 'children', 'child', 'sibling'])
|
|
|
|
export function findInReactFiber(
|
|
tree: Extract<ReactNode, { props: unknown }>,
|
|
filter: SearchFilter,
|
|
): any {
|
|
return findInTree(tree, filter, {
|
|
walkable: ReactFiberWalkable,
|
|
})
|
|
}
|