Skip to content

Commit 8db0631

Browse files
committedApr 13, 2022
Update for React 18
Closes GH-39.
1 parent e12085e commit 8db0631

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed
 

‎lib/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ export default function rehypeReact(options) {
8080
/**
8181
* @param {keyof JSX.IntrinsicElements} name
8282
* @param {Record<string, unknown>} props
83-
* @param {Array<unknown>} [children]
83+
* @param {Array<ReactNode>} [children]
8484
* @returns {ReactNode}
8585
*/
8686
function h(name, props, children) {

‎package.json

+9-5
Original file line numberDiff line numberDiff line change
@@ -47,19 +47,19 @@
4747
"dependencies": {
4848
"@mapbox/hast-util-table-cell-style": "^0.2.0",
4949
"@types/hast": "^2.0.0",
50-
"@types/react": "^17.0.0",
50+
"@types/react": "^18.0.0",
5151
"hast-to-hyperscript": "^10.0.0",
5252
"hast-util-whitespace": "^2.0.0",
5353
"unified": "^10.0.0"
5454
},
5555
"devDependencies": {
56-
"@types/react-dom": "^17.0.0",
56+
"@types/react-dom": "^18.0.0",
5757
"@types/tape": "^4.0.0",
5858
"c8": "^7.0.0",
5959
"hastscript": "^7.0.0",
6060
"prettier": "^2.0.0",
61-
"react": "^17.0.0",
62-
"react-dom": "^17.0.0",
61+
"react": "^18.0.0",
62+
"react-dom": "^18.0.0",
6363
"remark": "^14.0.0",
6464
"remark-cli": "^10.0.0",
6565
"remark-preset-wooorm": "^9.0.0",
@@ -86,7 +86,11 @@
8686
"trailingComma": "none"
8787
},
8888
"xo": {
89-
"prettier": true
89+
"prettier": true,
90+
"": "`xo` is wrong about file extensions",
91+
"rules": {
92+
"node/file-extension-in-import": "off"
93+
}
9094
},
9195
"remarkConfig": {
9296
"plugins": [

‎test.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import test from 'tape'
22
import React from 'react'
3-
import server from 'react-dom/server.js'
3+
import server from 'react-dom/server'
44
import {unified} from 'unified'
55
import {u} from 'unist-builder'
66
import {h} from 'hastscript'
@@ -199,6 +199,7 @@ test('React ' + React.version, (t) => {
199199
})
200200
.stringify(u('root', [headingNode, h('p')])),
201201
React.createElement('div', {}, [
202+
// @ts-expect-error: yeah it’s not okay per react types, but it works fine.
202203
React.createElement(Heading1, {key: 'h-2', node: headingNode}, undefined),
203204
React.createElement('p', {key: 'h-3'}, undefined)
204205
]),

0 commit comments

Comments
 (0)
Please sign in to comment.