Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: cleanup
Browse files Browse the repository at this point in the history
CodyJasonBennett committed Jan 10, 2025
1 parent c30d8a0 commit efda668
Showing 2 changed files with 15 additions and 6 deletions.
15 changes: 12 additions & 3 deletions packages/animated/src/withAnimated.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
import * as React from 'react'
import { forwardRef, useRef, Ref, useCallback, useEffect } from 'react'
import {
forwardRef,
useRef,
Ref,
useCallback,
useEffect,
MutableRefObject,
} from 'react'
import {
is,
each,
@@ -66,9 +73,11 @@ export const withAnimated = (Component: any, host: HostConfig) => {

const observer = new PropsObserver(callback, deps)

const observerRef = useRef<PropsObserver>(null)
// NOTE: useRef is bugged as immutable in 18.3 types
const observerRef = useRef<PropsObserver>(
null
) as MutableRefObject<PropsObserver | null>
useIsomorphicLayoutEffect(() => {
// @ts-expect-error useRef immutable in 18.3 types
observerRef.current = observer

// Observe the latest dependencies.
6 changes: 3 additions & 3 deletions packages/shared/src/hooks/useMemoOne.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useEffect, useRef, useState } from 'react'
import { useEffect, useRef, useState, MutableRefObject } from 'react'

type Cache<T> = {
inputs?: any[]
@@ -14,7 +14,8 @@ export function useMemoOne<T>(getResult: () => T, inputs?: any[]): T {
})
)

const committed = useRef<Cache<T>>(null)
// NOTE: useRef is bugged as immutable in 18.3 types
const committed = useRef<Cache<T>>(null) as MutableRefObject<Cache<T> | null>
const prevCache = committed.current

let cache = prevCache
@@ -33,7 +34,6 @@ export function useMemoOne<T>(getResult: () => T, inputs?: any[]): T {
}

useEffect(() => {
// @ts-expect-error useRef immutable in 18.3 types
committed.current = cache
if (prevCache == initial) {
initial.inputs = initial.result = undefined

0 comments on commit efda668

Please sign in to comment.