Skip to content

Commit 6fb28a3

Browse files
committed
feat: add support for React 19
Changes have been verified with React 18 in `react-plot`.
1 parent 4190423 commit 6fb28a3

File tree

8 files changed

+15
-15
lines changed

8 files changed

+15
-15
lines changed

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,14 @@
3737
"@storybook/addon-docs": "^9.0.8",
3838
"@storybook/addon-links": "^9.0.8",
3939
"@storybook/react-vite": "^9.0.8",
40-
"@types/react": "^18.3.11",
40+
"@types/react": "^19.1.7",
4141
"@zakodium/tsconfig": "^1.0.1",
4242
"eslint": "^9.28.0",
4343
"eslint-config-zakodium": "^15.0.1",
4444
"eslint-plugin-storybook": "^9.0.8",
4545
"prettier": "^3.5.3",
46-
"react": "^18.3.1",
47-
"react-dom": "^18.3.1",
46+
"react": "^19.1.0",
47+
"react-dom": "^19.1.0",
4848
"rimraf": "^6.0.1",
4949
"storybook": "^9.0.8",
5050
"typescript": "^5.8.3"

src/hooks/useBBoxObserver.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export function useBBoxObserver<ElementType extends SVGGraphicsElement>() {
1111
const previousSize = useRef(initialSize);
1212

1313
// Contains a function to cleanup the previous observer when the observed element changes.
14-
const cleanupPrevious = useRef<() => void>();
14+
const cleanupPrevious = useRef<() => void>(null);
1515

1616
// Ref callback to do the observation.
1717
const ref: RefCallback<ElementType> = useCallback((element) => {

src/hooks/useLinearPrimaryTicks.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { ScaleContinuousNumeric } from 'd3-scale';
2-
import type { MutableRefObject } from 'react';
2+
import type { RefObject } from 'react';
33
import { useState } from 'react';
44

55
import type { Tick } from './useTicks.js';
@@ -34,7 +34,7 @@ interface Options {
3434
export function useLinearPrimaryTicks(
3535
scale: ScaleContinuousNumeric<number, number>,
3636
direction: Directions,
37-
ref: MutableRefObject<SVGGElement | null>,
37+
ref: RefObject<SVGGElement | null>,
3838
options: Options = {},
3939
): UseLinearPrimaryTicksResult {
4040
const [ticks, setTicks] = useState<UseLinearPrimaryTicksResult>(() => ({

src/hooks/useLogTicks.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { ScaleContinuousNumeric } from 'd3-scale';
2-
import type { MutableRefObject } from 'react';
2+
import type { RefObject } from 'react';
33
import { useCallback, useEffect, useMemo, useState } from 'react';
44

55
import { textDimensions } from '../utils.js';
@@ -54,7 +54,7 @@ function formatTicks(
5454
export function useLogTicks(
5555
scale: ScaleContinuousNumeric<number, number>,
5656
direction: Directions,
57-
ref: MutableRefObject<SVGGElement | null>,
57+
ref: RefObject<SVGGElement | null>,
5858
options: Options = {},
5959
): PrimaryLogTicks[] {
6060
const [maxStrSize, setMaxStrSize] = useState(40);

src/hooks/useTicks.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { ScaleContinuousNumeric, ScaleTime } from 'd3-scale';
2-
import type { Dispatch, MutableRefObject, SetStateAction } from 'react';
2+
import type { Dispatch, RefObject, SetStateAction } from 'react';
33
import { useEffect } from 'react';
44

55
import { textDimensions } from '../utils.js';
@@ -40,7 +40,7 @@ export function useTicks<T extends number | Date>(
4040
? ScaleContinuousNumeric<number, number>
4141
: ScaleTime<number, number>,
4242
direction: Directions,
43-
ref: MutableRefObject<SVGGElement | null>,
43+
ref: RefObject<SVGGElement | null>,
4444
options: Options<T>,
4545
) {
4646
const range = scale.range() as [number, number];

src/hooks/useTimeTicks.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { ScaleTime } from 'd3-scale';
2-
import type { MutableRefObject } from 'react';
2+
import type { RefObject } from 'react';
33
import { useState } from 'react';
44

55
import type { Tick } from './useTicks.js';
@@ -34,7 +34,7 @@ interface Options {
3434
export function useTimeTicks(
3535
scale: ScaleTime<number, number>,
3636
direction: Directions,
37-
ref: MutableRefObject<SVGGElement | null>,
37+
ref: RefObject<SVGGElement | null>,
3838
options: Options,
3939
): UseTimeTicksResult {
4040
const { tickFormat = scale.tickFormat() } = options;

src/hooks/use_resize_observer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { useCallback, useRef, useState } from 'react';
22

33
export function useResizeObserver() {
44
const [size, setSize] = useState<DOMRect>();
5-
const observerRef = useRef<ResizeObserver | null>(null);
5+
const observerRef = useRef<ResizeObserver>(null);
66

77
const refCallback = useCallback((node: HTMLElement | null) => {
88
if (observerRef.current) {

src/utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import type { MutableRefObject } from 'react';
1+
import type { RefObject } from 'react';
22

33
export function textDimensions(
44
word: string,
5-
ref: MutableRefObject<SVGGElement | null>,
5+
ref: RefObject<SVGGElement | null>,
66
) {
77
const textContent = document.createTextNode(word);
88
const textElement = document.createElementNS(

0 commit comments

Comments
 (0)