Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
canifa_note
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Vũ Hoàng Anh
canifa_note
Commits
9b0cf8af
Commit
9b0cf8af
authored
Apr 01, 2022
by
email
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: upgrade react 18
parent
13684488
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
892 additions
and
975 deletions
+892
-975
package.json
web/package.json
+5
-5
Dialog.tsx
web/src/components/Dialog.tsx
+4
-3
Toast.tsx
web/src/components/Toast.tsx
+8
-7
main.tsx
web/src/main.tsx
+5
-4
yarn.lock
web/yarn.lock
+870
-956
No files found.
web/package.json
View file @
9b0cf8af
...
@@ -9,13 +9,13 @@
...
@@ -9,13 +9,13 @@
},
},
"dependencies"
:
{
"dependencies"
:
{
"lodash-es"
:
"^4.17.21"
,
"lodash-es"
:
"^4.17.21"
,
"react"
:
"^1
7.0.2
"
,
"react"
:
"^1
8.0.0
"
,
"react-dom"
:
"^1
7.0.2
"
"react-dom"
:
"^1
8.0.0
"
},
},
"devDependencies"
:
{
"devDependencies"
:
{
"@types/lodash-es"
:
"^4.17.5"
,
"@types/lodash-es"
:
"^4.17.5"
,
"@types/react"
:
"^17.0.
2
"
,
"@types/react"
:
"^17.0.
43
"
,
"@types/react-dom"
:
"^17.0.
2
"
,
"@types/react-dom"
:
"^17.0.
14
"
,
"@typescript-eslint/eslint-plugin"
:
"^5.6.0"
,
"@typescript-eslint/eslint-plugin"
:
"^5.6.0"
,
"@typescript-eslint/parser"
:
"^5.6.0"
,
"@typescript-eslint/parser"
:
"^5.6.0"
,
"@vitejs/plugin-react"
:
"^1.0.0"
,
"@vitejs/plugin-react"
:
"^1.0.0"
,
...
@@ -29,7 +29,7 @@
...
@@ -29,7 +29,7 @@
"prettier"
:
"2.5.1"
,
"prettier"
:
"2.5.1"
,
"tailwindcss"
:
"^3.0.18"
,
"tailwindcss"
:
"^3.0.18"
,
"typescript"
:
"^4.3.2"
,
"typescript"
:
"^4.3.2"
,
"vite"
:
"^2.
6.14
"
"vite"
:
"^2.
9.0
"
},
},
"license"
:
"MIT"
"license"
:
"MIT"
}
}
web/src/components/Dialog.tsx
View file @
9b0cf8af
import
ReactDOM
from
"react-dom
"
;
import
{
createRoot
}
from
"react-dom/client
"
;
import
appContext
from
"../stores/appContext"
;
import
appContext
from
"../stores/appContext"
;
import
Provider
from
"../labs/Provider"
;
import
Provider
from
"../labs/Provider"
;
import
appStore
from
"../stores/appStore"
;
import
appStore
from
"../stores/appStore"
;
...
@@ -39,6 +39,7 @@ export function showDialog<T extends DialogProps>(
...
@@ -39,6 +39,7 @@ export function showDialog<T extends DialogProps>(
props
?:
Omit
<
T
,
"destroy"
>
props
?:
Omit
<
T
,
"destroy"
>
):
DialogCallback
{
):
DialogCallback
{
const
tempDiv
=
document
.
createElement
(
"div"
);
const
tempDiv
=
document
.
createElement
(
"div"
);
const
dialog
=
createRoot
(
tempDiv
);
document
.
body
.
append
(
tempDiv
);
document
.
body
.
append
(
tempDiv
);
setTimeout
(()
=>
{
setTimeout
(()
=>
{
...
@@ -50,8 +51,8 @@ export function showDialog<T extends DialogProps>(
...
@@ -50,8 +51,8 @@ export function showDialog<T extends DialogProps>(
tempDiv
.
firstElementChild
?.
classList
.
remove
(
"showup"
);
tempDiv
.
firstElementChild
?.
classList
.
remove
(
"showup"
);
tempDiv
.
firstElementChild
?.
classList
.
add
(
"showoff"
);
tempDiv
.
firstElementChild
?.
classList
.
add
(
"showoff"
);
setTimeout
(()
=>
{
setTimeout
(()
=>
{
dialog
.
unmount
();
tempDiv
.
remove
();
tempDiv
.
remove
();
ReactDOM
.
unmountComponentAtNode
(
tempDiv
);
},
ANIMATION_DURATION
);
},
ANIMATION_DURATION
);
},
},
};
};
...
@@ -75,7 +76,7 @@ export function showDialog<T extends DialogProps>(
...
@@ -75,7 +76,7 @@ export function showDialog<T extends DialogProps>(
);
);
}
}
ReactDOM
.
render
(
Fragment
,
tempDiv
);
dialog
.
render
(
Fragment
);
return
cbs
;
return
cbs
;
}
}
web/src/components/Toast.tsx
View file @
9b0cf8af
import
{
useEffect
}
from
"react"
;
import
{
useEffect
}
from
"react"
;
import
ReactDOM
from
"react-dom
"
;
import
{
createRoot
,
Root
}
from
"react-dom/client
"
;
import
{
TOAST_ANIMATION_DURATION
}
from
"../helpers/consts"
;
import
{
TOAST_ANIMATION_DURATION
}
from
"../helpers/consts"
;
import
"../less/toast.less"
;
import
"../less/toast.less"
;
...
@@ -39,7 +39,7 @@ const Toast: React.FC<ToastItemProps> = (props: ToastItemProps) => {
...
@@ -39,7 +39,7 @@ const Toast: React.FC<ToastItemProps> = (props: ToastItemProps) => {
class
ToastHelper
{
class
ToastHelper
{
private
shownToastAmount
=
0
;
private
shownToastAmount
=
0
;
private
toastWrapper
:
HTMLDivElement
;
private
toastWrapper
:
HTMLDivElement
;
private
shownToastContainers
:
HTMLDivElement
[]
=
[];
private
shownToastContainers
:
[
Root
,
HTMLDivElement
]
[]
=
[];
constructor
()
{
constructor
()
{
const
wrapperClassName
=
"toast-list-container"
;
const
wrapperClassName
=
"toast-list-container"
;
...
@@ -63,10 +63,11 @@ class ToastHelper {
...
@@ -63,10 +63,11 @@ class ToastHelper {
private
showToast
=
(
config
:
ToastConfig
)
=>
{
private
showToast
=
(
config
:
ToastConfig
)
=>
{
const
tempDiv
=
document
.
createElement
(
"div"
);
const
tempDiv
=
document
.
createElement
(
"div"
);
const
toast
=
createRoot
(
tempDiv
);
tempDiv
.
className
=
`toast-wrapper
${
config
.
type
}
`
;
tempDiv
.
className
=
`toast-wrapper
${
config
.
type
}
`
;
this
.
toastWrapper
.
appendChild
(
tempDiv
);
this
.
toastWrapper
.
appendChild
(
tempDiv
);
this
.
shownToastAmount
++
;
this
.
shownToastAmount
++
;
this
.
shownToastContainers
.
push
(
tempDiv
);
this
.
shownToastContainers
.
push
(
[
toast
,
tempDiv
]
);
setTimeout
(()
=>
{
setTimeout
(()
=>
{
tempDiv
.
classList
.
add
(
"showup"
);
tempDiv
.
classList
.
add
(
"showup"
);
...
@@ -83,9 +84,9 @@ class ToastHelper {
...
@@ -83,9 +84,9 @@ class ToastHelper {
this
.
shownToastAmount
--
;
this
.
shownToastAmount
--
;
if
(
this
.
shownToastAmount
===
0
)
{
if
(
this
.
shownToastAmount
===
0
)
{
for
(
const
d
of
this
.
shownToastContainers
)
{
for
(
const
[
root
,
tempDiv
]
of
this
.
shownToastContainers
)
{
ReactDOM
.
unmountComponentAtNode
(
d
);
root
.
unmount
(
);
d
.
remove
();
tempDiv
.
remove
();
}
}
this
.
shownToastContainers
.
splice
(
0
,
this
.
shownToastContainers
.
length
);
this
.
shownToastContainers
.
splice
(
0
,
this
.
shownToastContainers
.
length
);
}
}
...
@@ -93,7 +94,7 @@ class ToastHelper {
...
@@ -93,7 +94,7 @@ class ToastHelper {
},
},
};
};
ReactDOM
.
render
(<
Toast
{
...
config
}
destory=
{
cbs
.
destory
}
/>,
tempDiv
);
toast
.
render
(<
Toast
{
...
config
}
destory=
{
cbs
.
destory
}
/>
);
return
cbs
;
return
cbs
;
};
};
...
...
web/src/main.tsx
View file @
9b0cf8af
import
React
from
"react"
;
import
React
from
"react"
;
import
ReactDOM
from
"react-dom
"
;
import
{
createRoot
}
from
"react-dom/client
"
;
import
Provider
from
"./labs/Provider"
;
import
Provider
from
"./labs/Provider"
;
import
appContext
from
"./stores/appContext"
;
import
appContext
from
"./stores/appContext"
;
import
appStore
from
"./stores/appStore"
;
import
appStore
from
"./stores/appStore"
;
...
@@ -8,11 +8,12 @@ import "./helpers/polyfill";
...
@@ -8,11 +8,12 @@ import "./helpers/polyfill";
import
"./less/global.less"
;
import
"./less/global.less"
;
import
"./css/index.css"
;
import
"./css/index.css"
;
ReactDOM
.
render
(
const
container
=
document
.
getElementById
(
"root"
);
const
root
=
createRoot
(
container
as
HTMLElement
);
root
.
render
(
<
React
.
StrictMode
>
<
React
.
StrictMode
>
<
Provider
store=
{
appStore
}
context=
{
appContext
}
>
<
Provider
store=
{
appStore
}
context=
{
appContext
}
>
<
App
/>
<
App
/>
</
Provider
>
</
Provider
>
</
React
.
StrictMode
>,
</
React
.
StrictMode
>
document
.
getElementById
(
"root"
)
);
);
web/yarn.lock
View file @
9b0cf8af
This source diff could not be displayed because it is too large. You can
view the blob
instead.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment