mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-09 10:34:17 +00:00
improve lifecycle
This commit is contained in:
parent
3dc5715734
commit
45075ee8a8
@ -9,10 +9,13 @@ import "./index.less"
|
|||||||
const CoverEditor = (props) => {
|
const CoverEditor = (props) => {
|
||||||
const { value, onChange, defaultUrl } = props
|
const { value, onChange, defaultUrl } = props
|
||||||
|
|
||||||
|
const [init, setInit] = React.useState(true)
|
||||||
const [url, setUrl] = React.useState(value)
|
const [url, setUrl] = React.useState(value)
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
onChange(url)
|
if (!init) {
|
||||||
|
onChange(url)
|
||||||
|
}
|
||||||
}, [url])
|
}, [url])
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
@ -21,6 +24,8 @@ const CoverEditor = (props) => {
|
|||||||
} else {
|
} else {
|
||||||
setUrl(value)
|
setUrl(value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setInit(false)
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
return <div className="cover-editor">
|
return <div className="cover-editor">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user