Skip to content

Commit 939a982

Browse files
committed
chore: upgrade to react 19
update JSX usage add changeset
1 parent 306c326 commit 939a982

20 files changed

Lines changed: 46 additions & 32 deletions

File tree

.changeset/loud-shoes-promise.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@storefront-ui/react': major
3+
---
4+
5+
- **[BREAKING][CHANGED]** upgrade to React 19. There are no breaking changes specific to SFUI library itself. To upgrade, please [follow official React guide](https://react.dev/blog/2024/04/25/react-19-upgrade-guide).

_templates/component/new/react_component.ejs.t

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22
to: packages/sfui/frameworks/react/components/<%= name %>/<%= name %>.tsx
33
force: false
44
---
5+
import React from 'react';
56
<% Props = name + 'Props' %>import type { <%= Props %> } from './types';
67

78
export default function <%= name %>({
89
...attributes
9-
}: <%= Props %>): JSX.Element {
10+
}: <%= Props %>): React.JSX.Element {
1011
return (
1112

1213
);

apps/preview/next/components/utils/Controls.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import classNames from 'classnames';
2-
import { ChangeEvent, useState } from 'react';
2+
import React, { ChangeEvent, useState } from 'react';
33
import { SfButton, SfButtonVariant, SfButtonSize, SfIconExpandLess, SfIconExpandMore } from '@storefront-ui/react';
44
import { useControlsSearchParams } from '../../composables/utils/useControlsSearchParams';
55
import { ControlOptionBind, ControlsProps, ControlsType } from './types';
@@ -100,7 +100,7 @@ export default function Controls<T extends { [k: string]: any }>({ controls, sta
100100
<span id={control.modelName}>{control.modelName}</span>
101101
</td>
102102
<td className="value">
103-
{((): JSX.Element | JSX.Element[] => {
103+
{((): React.JSX.Element | React.JSX.Element[] => {
104104
switch (control.type) {
105105
case 'select':
106106
return (

apps/preview/next/pages/showcases/Gallery/GalleryVertical.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import { ShowcasePageLayout } from '../../showcases';
44

55
// #region source
6-
import { useRef, useState } from 'react';
6+
import { type RefObject, useRef, useState } from 'react';
77
import { useIntersection } from 'react-use';
88
import {
99
SfScrollable,
@@ -36,13 +36,13 @@ export default function GalleryVertical() {
3636
const firstThumbRef = useRef<HTMLButtonElement>(null);
3737
const [activeIndex, setActiveIndex] = useState(0);
3838

39-
const firstThumbVisible = useIntersection(firstThumbRef, {
39+
const firstThumbVisible = useIntersection(firstThumbRef as RefObject<HTMLElement>, {
4040
root: thumbsRef.current,
4141
rootMargin: '0px',
4242
threshold: 1,
4343
});
4444

45-
const lastThumbVisible = useIntersection(lastThumbRef, {
45+
const lastThumbVisible = useIntersection(lastThumbRef as RefObject<HTMLElement>, {
4646
root: thumbsRef.current,
4747
rootMargin: '0px',
4848
threshold: 1,

apps/preview/next/pages/showcases/MegaMenu/MegaMenuNavigation.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ export default function MegaMenuNavigation() {
392392
const [inputValue, setInputValue] = useState('');
393393

394394
const refsByKey = useMemo(() => {
395-
const buttonRefs: Record<string, RefObject<HTMLButtonElement>> = {};
395+
const buttonRefs: Record<string, RefObject<HTMLButtonElement | null>> = {};
396396
content.children?.forEach((item) => {
397397
buttonRefs[item.key] = createRef();
398398
});

apps/preview/next/pages/showcases/Search/SearchWithButton.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/* eslint-disable no-console */
33
import { ShowcasePageLayout } from '../../showcases';
44
// #region source
5-
import { type ChangeEvent, type FormEvent, type KeyboardEvent, useState, useRef } from 'react';
5+
import React, { type ChangeEvent, type FormEvent, type KeyboardEvent, useState, useRef } from 'react';
66
import { useDebounce } from 'react-use';
77
import { offset } from '@floating-ui/react-dom';
88
import {
@@ -21,7 +21,7 @@ import {
2121
interface Product {
2222
id: string;
2323
name: string;
24-
thumbnail?: JSX.Element;
24+
thumbnail?: React.JSX.Element;
2525
image?: string;
2626
}
2727

packages/sfui/frameworks/react/components/SfBadge/SfBadge.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import React from 'react';
12
import { SfBadgePlacement } from '@storefront-ui/shared';
23
import { twMerge, type SfBadgeProps } from '@storefront-ui/react';
34

@@ -8,7 +9,7 @@ export default function SfBadge({
89
placement = SfBadgePlacement['top-right'],
910
className,
1011
...attributes
11-
}: SfBadgeProps): JSX.Element {
12+
}: SfBadgeProps): React.JSX.Element {
1213
const isDot = variant === 'dot';
1314
let displayValue = content;
1415
if (isDot) {

packages/sfui/frameworks/react/components/SfCheckbox/SfCheckbox.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useRef, useEffect, useState } from 'react';
1+
import React, { useRef, useEffect, useState } from 'react';
22
import {
33
mergeRefs,
44
SfIconCheckBox,
@@ -15,7 +15,7 @@ const SfCheckbox = polymorphicForwardRef<'input', SfCheckboxProps>(
1515
(
1616
{ wrapperAs, invalid, className, indeterminate: indeterminateProp, wrapperClassName, ...attributes },
1717
ref,
18-
): JSX.Element => {
18+
): React.JSX.Element => {
1919
const inputRef = useRef<HTMLInputElement>(null);
2020
const WrapperTag = wrapperAs || defaultWrapperTag;
2121
const [isIndeterminate, setIsIndeterminate] = useState(indeterminateProp || false);

packages/sfui/frameworks/react/components/SfCounter/SfCounter.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import React from 'react';
12
import type { SfCounterProps } from '@storefront-ui/react';
23
import { SfCounterSize, twMerge } from '@storefront-ui/react';
34

@@ -7,7 +8,7 @@ export default function SfCounter({
78
children,
89
className,
910
...attributes
10-
}: SfCounterProps): JSX.Element {
11+
}: SfCounterProps): React.JSX.Element {
1112
const sizeClasses: Record<SfCounterSize, string> = {
1213
[SfCounterSize['3xs']]: twMerge('text-3xs', { 'px-1': pill }),
1314
[SfCounterSize['2xs']]: twMerge('text-2xs', { 'px-1.5': pill }),

packages/sfui/frameworks/react/components/SfLoaderCircular/SfLoaderCircular.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import React from 'react';
12
import { SfLoaderSize, twMerge } from '@storefront-ui/react';
23
import type { SfLoaderCircularProps } from '@storefront-ui/react';
34

@@ -29,7 +30,7 @@ export default function SfLoaderCircular({
2930
className,
3031
circleClassName,
3132
...attributes
32-
}: SfLoaderCircularProps): JSX.Element {
33+
}: SfLoaderCircularProps): React.JSX.Element {
3334
return (
3435
<svg
3536
className={twMerge(

0 commit comments

Comments
 (0)