Skip to content

Commit fb09fba

Browse files
authored
Merge pull request #90 from LGLabGreg/feat-react-18-support
Feat react 18 support for ref
2 parents 48ccfcd + 4e061e9 commit fb09fba

6 files changed

Lines changed: 1696 additions & 101 deletions

File tree

.changeset/wicked-mangos-cry.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@lglab/react-qr-code': patch
3+
---
4+
5+
Add ref to ReactQRCodeProps

.changeset/young-jeans-count.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@lglab/react-qr-code': patch
3+
---
4+
5+
Use forwardRef to support React 18

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"type": "git",
66
"url": "https://github.com/LGLabGreg/react-qr-code.git"
77
},
8-
"packageManager": "pnpm@10.2.1",
8+
"packageManager": "pnpm@10.4.1",
99
"type": "module",
1010
"scripts": {
1111
"dev": "pnpm concurrently --names packages,apps \"pnpm watch:packages\" \"pnpm watch:apps\"",
@@ -49,7 +49,7 @@
4949
"react": "^19.0.0",
5050
"react-dom": "^19.0.0",
5151
"typescript": "~5.7.3",
52-
"typescript-eslint": "^8.24.1",
52+
"typescript-eslint": "^8.25.0",
5353
"vite": "^6.1.1",
5454
"vitest": "^3.0.5"
5555
}

packages/react-qr-code/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@
5757
"react": "^19.0.0",
5858
"react-dom": "^19.0.0",
5959
"typescript": "~5.7.3",
60-
"typescript-eslint": "^8.24.1",
61-
"vite": "^6.1.1",
60+
"typescript-eslint": "^8.25.0",
61+
"vite": "^6.2.0",
6262
"vite-plugin-dts": "^4.5.0"
6363
}
6464
}

packages/react-qr-code/src/react-qr-code.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useImperativeHandle, useRef } from 'react'
1+
import { forwardRef, useImperativeHandle, useRef } from 'react'
22

33
import { Background } from './components/background'
44
import { DataModules } from './components/data-modules'
@@ -13,13 +13,12 @@ import {
1313
} from './constants'
1414
import { useIds } from './hooks/use-ids'
1515
import { useQRCode } from './hooks/use-qr-code'
16-
import type { DownloadOptions, ReactQRCodeProps } from './types/lib'
16+
import type { DownloadOptions, ReactQRCodeProps, ReactQRCodeRef } from './types/lib'
1717
import { downloadRaster, downloadSVG } from './utils/download'
1818
import { excavateModules } from './utils/qr-code'
1919

20-
const ReactQRCode = (props: ReactQRCodeProps) => {
20+
const ReactQRCode = forwardRef<ReactQRCodeRef, ReactQRCodeProps>((props, ref) => {
2121
const {
22-
ref,
2322
value,
2423
size = DEFAULT_SIZE,
2524
level = DEFAULT_LEVEL,
@@ -125,7 +124,7 @@ const ReactQRCode = (props: ReactQRCodeProps) => {
125124
{image}
126125
</svg>
127126
)
128-
}
127+
})
129128

130129
ReactQRCode.displayName = 'ReactQRCode'
131130

0 commit comments

Comments
 (0)