Skip to content

Commit

Permalink
Revert "experiment: keep MutableRefObject"
Browse files Browse the repository at this point in the history
This reverts commit 6c06950.
  • Loading branch information
CodyJasonBennett committed Jan 10, 2025
1 parent 33364f8 commit 51312c3
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion packages/core/src/hooks/useInView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { Valid } from '../types/common'

export interface IntersectionArgs
extends Omit<IntersectionObserverInit, 'root' | 'threshold'> {
root?: React.MutableRefObject<HTMLElement>
root?: React.RefObject<HTMLElement>
once?: boolean
amount?: 'any' | 'all' | number | number[]
}
Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/hooks/useResize.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { MutableRefObject } from 'react'
import { RefObject } from 'react'
import { onResize, each, useIsomorphicLayoutEffect } from '@react-spring/shared'

import { SpringProps, SpringValues } from '../types'

import { useSpring } from './useSpring'

export interface UseResizeOptions extends Omit<SpringProps, 'to' | 'from'> {
container?: MutableRefObject<HTMLElement | null | undefined>
container?: RefObject<HTMLElement | null | undefined>
}

/**
Expand All @@ -30,7 +30,7 @@ export interface UseResizeOptions extends Omit<SpringProps, 'to' | 'from'> {
```
*
* @param {UseResizeOptions} UseResizeOptions options for the useScroll hook.
* @param {MutableRefObject<HTMLElement>} UseResizeOptions.container the container to listen to scroll events on, defaults to the window.
* @param {RefObject<HTMLElement>} UseResizeOptions.container the container to listen to scroll events on, defaults to the window.
*
* @returns {SpringValues<{width: number; height: number;}>} SpringValues the collection of values returned from the inner hook
*/
Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/hooks/useScroll.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { MutableRefObject } from 'react'
import { RefObject } from 'react'
import { each, onScroll, useIsomorphicLayoutEffect } from '@react-spring/shared'

import { SpringProps, SpringValues } from '../types'

import { useSpring } from './useSpring'

export interface UseScrollOptions extends Omit<SpringProps, 'to' | 'from'> {
container?: MutableRefObject<HTMLElement>
container?: RefObject<HTMLElement>
}

/**
Expand All @@ -30,7 +30,7 @@ export interface UseScrollOptions extends Omit<SpringProps, 'to' | 'from'> {
```
*
* @param {UseScrollOptions} useScrollOptions options for the useScroll hook.
* @param {MutableRefObject<HTMLElement>} useScrollOptions.container the container to listen to scroll events on, defaults to the window.
* @param {RefObject<HTMLElement>} useScrollOptions.container the container to listen to scroll events on, defaults to the window.
*
* @returns {SpringValues<{scrollX: number; scrollY: number; scrollXProgress: number; scrollYProgress: number}>} SpringValues the collection of values returned from the inner hook
*/
Expand Down
4 changes: 2 additions & 2 deletions packages/parallax/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ export interface IParallax {
current: number
controller: Controller<{ scroll: number }>
layers: Set<IParallaxLayer>
container: React.MutableRefObject<any>
content: React.MutableRefObject<any>
container: React.RefObject<any>
content: React.RefObject<any>
scrollTo(offset: number): void
update(): void
stop(): void
Expand Down
4 changes: 2 additions & 2 deletions packages/types/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
*/

import * as React from 'react'
import { ReactElement, MutableRefObject } from 'react'
import { ReactElement, RefObject } from 'react'

/** Ensure each type of `T` is an array */
export type Arrify<T> = [T, T] extends [infer T, infer DT]
Expand Down Expand Up @@ -139,7 +139,7 @@ export interface Disposable {
}

// react.d.ts
export type RefProp<T> = MutableRefObject<T | null | undefined>
export type RefProp<T> = RefObject<T | null | undefined>

// https://github.com/DefinitelyTyped/DefinitelyTyped/issues/34237
export type ElementType<P = any> =
Expand Down

0 comments on commit 51312c3

Please sign in to comment.