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 { value, onChange, defaultUrl } = props
|
||||
|
||||
const [init, setInit] = React.useState(true)
|
||||
const [url, setUrl] = React.useState(value)
|
||||
|
||||
React.useEffect(() => {
|
||||
if (!init) {
|
||||
onChange(url)
|
||||
}
|
||||
}, [url])
|
||||
|
||||
React.useEffect(() => {
|
||||
@ -21,6 +24,8 @@ const CoverEditor = (props) => {
|
||||
} else {
|
||||
setUrl(value)
|
||||
}
|
||||
|
||||
setInit(false)
|
||||
}, [])
|
||||
|
||||
return <div className="cover-editor">
|
||||
|
Loading…
x
Reference in New Issue
Block a user