refactor
This commit is contained in:
parent
76f0b040ad
commit
d603f48bad
@ -1,8 +1,9 @@
|
||||
import React, { useState, useEffect } from 'react'
|
||||
import React, { useState } from 'react'
|
||||
import ReactDOM from 'react-dom'
|
||||
import { hot } from 'react-hot-loader/root'
|
||||
import { t } from '@/scripts/i18n'
|
||||
import useBlessingExtra from '@/scripts/hooks/useBlessingExtra'
|
||||
import useMount from '@/scripts/hooks/useMount'
|
||||
import * as fetch from '@/scripts/net'
|
||||
import { showModal, toast } from '@/scripts/notify'
|
||||
import { isAlex } from '@/scripts/textureUtils'
|
||||
@ -12,8 +13,6 @@ import ViewerSkeleton from '@/components/ViewerSkeleton'
|
||||
|
||||
const Previewer = React.lazy(() => import('@/components/Viewer'))
|
||||
|
||||
const container = document.createElement('div')
|
||||
|
||||
const Upload: React.FC = () => {
|
||||
const [name, setName] = useState('')
|
||||
const [type, setType] = useState<TextureType>('steve')
|
||||
@ -29,14 +28,7 @@ const Upload: React.FC = () => {
|
||||
const scorePrivate = useBlessingExtra<number>('scorePrivate')
|
||||
const closetItemCost = useBlessingExtra<number>('closetItemCost')
|
||||
|
||||
useEffect(() => {
|
||||
const mount = document.querySelector('#previewer')!
|
||||
mount.appendChild(container)
|
||||
|
||||
return () => {
|
||||
mount.removeChild(container)
|
||||
}
|
||||
}, [])
|
||||
const container = useMount('#previewer')
|
||||
|
||||
const handleNameChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
||||
setName(event.target.value)
|
||||
|
@ -1,5 +1,6 @@
|
||||
import React, { useEffect } from 'react'
|
||||
import React from 'react'
|
||||
import ReactDOM from 'react-dom'
|
||||
import useMount from '@/scripts/hooks/useMount'
|
||||
import ViewerSkeleton from '@/components/ViewerSkeleton'
|
||||
|
||||
const Viewer = React.lazy(() => import('@/components/Viewer'))
|
||||
@ -10,17 +11,8 @@ interface Props {
|
||||
isAlex: boolean
|
||||
}
|
||||
|
||||
const container = document.createElement('div')
|
||||
|
||||
const Previewer: React.FC<Props> = props => {
|
||||
useEffect(() => {
|
||||
const mount = document.querySelector('#previewer')!
|
||||
mount.appendChild(container)
|
||||
|
||||
return () => {
|
||||
mount.removeChild(container)
|
||||
}
|
||||
}, [])
|
||||
const container = useMount('#previewer')
|
||||
|
||||
const skin = props.skin ? `${blessing.base_url}/textures/${props.skin}` : ''
|
||||
const cape = props.cape ? `${blessing.base_url}/textures/${props.cape}` : ''
|
||||
|
@ -1,5 +1,6 @@
|
||||
import React, { useState, useEffect } from 'react'
|
||||
import React, { useState } from 'react'
|
||||
import ReactDOM from 'react-dom'
|
||||
import useMount from '@/scripts/hooks/useMount'
|
||||
import { t } from '@/scripts/i18n'
|
||||
import ViewerSkeleton from '@/components/ViewerSkeleton'
|
||||
import Viewer2d from './Viewer2d'
|
||||
@ -12,19 +13,10 @@ interface Props {
|
||||
isAlex: boolean
|
||||
}
|
||||
|
||||
const container = document.createElement('div')
|
||||
|
||||
const Previewer: React.FC<Props> = props => {
|
||||
const [is3d, setIs3d] = useState(true)
|
||||
|
||||
useEffect(() => {
|
||||
const mount = document.querySelector('#previewer')!
|
||||
mount.appendChild(container)
|
||||
|
||||
return () => {
|
||||
mount.removeChild(container)
|
||||
}
|
||||
}, [])
|
||||
const container = useMount('#previewer')
|
||||
|
||||
const switchMode = () => setIs3d(is => !is)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user