Skip to content

Commit a6ed909

Browse files
author
Zaydek Michels-Gualtieri
committed
Upgraded to react@next react-dom@next and (forcibly) removed warnings
1 parent d3719e6 commit a6ed909

5 files changed

Lines changed: 37 additions & 26 deletions

File tree

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
"dependencies": {
44
"emoji-trie": "https://github.com/codex-src/emoji-trie.js",
55
"lodash": "^4.17.19",
6-
"react": "^16.13.1",
7-
"react-dom": "^16.13.1",
6+
"react": "next",
7+
"react-dom": "next",
88
"react-scripts": "next",
99
"use-immer": "^0.4.1",
1010
"uuidv4": "^6.1.0"

src/Editor/Editor.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ const Editor = ({ id, className, style, state, dispatch, children }) => {
3232
const pointerdownRef = React.useRef(false)
3333

3434
// Mounts elements from props.children (once).
35+
//
36+
// eslint-disable-next-line react-hooks/exhaustive-deps
3537
React.useLayoutEffect(
3638
React.useCallback(() => {
3739
const elements = initElementsFromChildren(children)
@@ -44,6 +46,8 @@ const Editor = ({ id, className, style, state, dispatch, children }) => {
4446
)
4547

4648
// Rerenders on state.shouldRerender.
49+
//
50+
// eslint-disable-next-line react-hooks/exhaustive-deps
4751
React.useLayoutEffect(
4852
React.useCallback(() => {
4953
// https://bugs.chromium.org/p/chromium/issues/detail?id=138439#c10

src/Editor/useEditor/useEditor.js

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import React from "react"
44
import { initElementsFromMarkup } from "../parsers"
55
import { useImmerReducer } from "use-immer"
66

7-
const newInitialState = () => ({
7+
const initialState = {
88
mounted: false,
99
focused: false,
1010
elements: [
@@ -28,7 +28,7 @@ const newInitialState = () => ({
2828
},
2929
rangeTypes: {},
3030
shouldRerender: 0,
31-
})
31+
}
3232

3333
function EditorReducer(e, action) {
3434
switch (action.type) {
@@ -64,17 +64,20 @@ function EditorReducer(e, action) {
6464
}
6565
}
6666

67-
// Instantiates an editor from markup.
67+
// Instantiates an editor state from markup.
6868
export function useEditorFromMarkup(markup) {
69-
const initialState = React.useMemo(() => {
69+
const state = React.useMemo(() => {
7070
const elements = initElementsFromMarkup(markup)
71-
return newInitialState(elements)
71+
const state = {
72+
...initialState,
73+
elements,
74+
}
75+
return state
7276
}, [markup])
73-
return useImmerReducer(EditorReducer, initialState)
77+
return useImmerReducer(EditorReducer, state)
7478
}
7579

76-
// Instantiates an editor.
80+
// Instantiates an editor state.
7781
export function useEditor() {
78-
const initialState = React.useMemo(newInitialState)
7982
return useImmerReducer(EditorReducer, initialState)
8083
}

src/EditorApp/EditorApp.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ const EditorApp = () => {
2323

2424
// Mounts deferred elements to preferences (because of the
2525
// props.children pattern).
26+
//
27+
// eslint-disable-next-line react-hooks/exhaustive-deps
2628
React.useEffect(
2729
React.useCallback(() => {
2830
if (state.mounted) {
@@ -53,6 +55,8 @@ const EditorApp = () => {
5355
}, [prefs.readOnlyMode])
5456

5557
// Manages rendered markdown.
58+
//
59+
// eslint-disable-next-line react-hooks/exhaustive-deps
5660
React.useEffect(
5761
React.useCallback(() => {
5862
if (prefs.show) {
@@ -69,6 +73,8 @@ const EditorApp = () => {
6973
)
7074

7175
// Manages rendered markup.
76+
//
77+
// eslint-disable-next-line react-hooks/exhaustive-deps
7278
React.useEffect(
7379
React.useCallback(() => {
7480
if (prefs.show) {

yarn.lock

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9333,7 +9333,7 @@ prompts@^2.0.1:
93339333
kleur "^3.0.3"
93349334
sisteransi "^1.0.4"
93359335

9336-
prop-types@^15.6.2, prop-types@^15.7.2:
9336+
prop-types@^15.7.2:
93379337
version "15.7.2"
93389338
resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.7.2.tgz#52c41e75b8c87e72b9d9360e0206b99dcbffa6c5"
93399339
integrity sha512-8QQikdH7//R2vurIJSutZ1smHYTcLpRWEOlHnzcWHmBYrOGUysKwSsrC89BCiFj3CbrfJ/nXFdJepOVrY1GCHQ==
@@ -9559,15 +9559,14 @@ react-dev-utils@11.0.0-next.77+3d74b79d:
95599559
strip-ansi "6.0.0"
95609560
text-table "0.2.0"
95619561

9562-
react-dom@^16.13.1:
9563-
version "16.13.1"
9564-
resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-16.13.1.tgz#c1bd37331a0486c078ee54c4740720993b2e0e7f"
9565-
integrity sha512-81PIMmVLnCNLO/fFOQxdQkvEq/+Hfpv24XNJfpyZhTRfO0QcmQIF/PgCa1zCOj2w1hrn12MFLyaJ/G0+Mxtfag==
9562+
react-dom@next:
9563+
version "17.0.0-rc.0"
9564+
resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-17.0.0-rc.0.tgz#237b4cca9cf817329373424bde00736f11fd7541"
9565+
integrity sha512-Ny2SlnMe+SxWRVDX2aLyWsv3ltbJC0gVyWtedfoJnV2265ePcM8BLY9fJjKb4ZXwcQ+pwZFdsURYarJ5qEEMeQ==
95669566
dependencies:
95679567
loose-envify "^1.1.0"
95689568
object-assign "^4.1.1"
9569-
prop-types "^15.6.2"
9570-
scheduler "^0.19.1"
9569+
scheduler "0.20.0-rc.0"
95719570

95729571
react-error-overlay@7.0.0-next.77+3d74b79d:
95739572
version "7.0.0-next.77"
@@ -9647,14 +9646,13 @@ react-scripts@next:
96479646
optionalDependencies:
96489647
fsevents "^2.1.3"
96499648

9650-
react@^16.13.1:
9651-
version "16.13.1"
9652-
resolved "https://registry.yarnpkg.com/react/-/react-16.13.1.tgz#2e818822f1a9743122c063d6410d85c1e3afe48e"
9653-
integrity sha512-YMZQQq32xHLX0bz5Mnibv1/LHb3Sqzngu7xstSM+vrkE5Kzr9xE0yMByK5kMoTK30YVJE61WfbxIFFvfeDKT1w==
9649+
react@next:
9650+
version "17.0.0-rc.0"
9651+
resolved "https://registry.yarnpkg.com/react/-/react-17.0.0-rc.0.tgz#91a4d2085f07b501175a2434bd65b35aa0e95686"
9652+
integrity sha512-GPOdeCEE5HL9jRh7YIXoqBBxQVTqKtMm7tbH0Q//PJZV9EkFyUSDUglvIO/0i42PuUstEBcmOwlodTV2R9iStg==
96549653
dependencies:
96559654
loose-envify "^1.1.0"
96569655
object-assign "^4.1.1"
9657-
prop-types "^15.6.2"
96589656

96599657
read-pkg-up@^2.0.0:
96609658
version "2.0.0"
@@ -10203,10 +10201,10 @@ saxes@^5.0.0:
1020310201
dependencies:
1020410202
xmlchars "^2.2.0"
1020510203

10206-
scheduler@^0.19.1:
10207-
version "0.19.1"
10208-
resolved "https://registry.yarnpkg.com/scheduler/-/scheduler-0.19.1.tgz#4f3e2ed2c1a7d65681f4c854fa8c5a1ccb40f196"
10209-
integrity sha512-n/zwRWRYSUj0/3g/otKDRPMh6qv2SYMWNq85IEa8iZyAv8od9zDYpGSnpBEjNgcMNq6Scbu5KfIPxNF72R/2EA==
10204+
scheduler@0.20.0-rc.0:
10205+
version "0.20.0-rc.0"
10206+
resolved "https://registry.yarnpkg.com/scheduler/-/scheduler-0.20.0-rc.0.tgz#9cb397f88f9decea28d159d3aad068b54a6f35e4"
10207+
integrity sha512-5CZiVhk9xI9VmqaodZH+eO3aKgqYwjZ8uf9lnfRlYEwaB4lbmIq0mzuNY5w52sbPlZP9pifXQaLGudKHMgQZcw==
1021010208
dependencies:
1021110209
loose-envify "^1.1.0"
1021210210
object-assign "^4.1.1"

0 commit comments

Comments
 (0)