Don't render stuff whenever window size changes (#978)
This commit is contained in:
		
							parent
							
								
									89e26d077e
								
							
						
					
					
						commit
						dc0b6dc6a6
					
				| 
						 | 
				
			
			@ -5,7 +5,7 @@ import { formatMoney } from 'common/util/format'
 | 
			
		|||
import { Col } from './layout/col'
 | 
			
		||||
import { SiteLink } from './site-link'
 | 
			
		||||
import { ENV_CONFIG } from 'common/envs/constants'
 | 
			
		||||
import { useWindowSize } from 'web/hooks/use-window-size'
 | 
			
		||||
import { useIsMobile } from 'web/hooks/use-is-mobile'
 | 
			
		||||
import { Row } from './layout/row'
 | 
			
		||||
 | 
			
		||||
export function AmountInput(props: {
 | 
			
		||||
| 
						 | 
				
			
			@ -36,8 +36,7 @@ export function AmountInput(props: {
 | 
			
		|||
    onChange(isInvalid ? undefined : amount)
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  const { width } = useWindowSize()
 | 
			
		||||
  const isMobile = (width ?? 0) < 768
 | 
			
		||||
  const isMobile = useIsMobile(768)
 | 
			
		||||
 | 
			
		||||
  return (
 | 
			
		||||
    <>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -47,7 +47,6 @@ import { Modal } from './layout/modal'
 | 
			
		|||
import { Title } from './title'
 | 
			
		||||
import toast from 'react-hot-toast'
 | 
			
		||||
import { CheckIcon } from '@heroicons/react/solid'
 | 
			
		||||
import { useWindowSize } from 'web/hooks/use-window-size'
 | 
			
		||||
 | 
			
		||||
export function BetPanel(props: {
 | 
			
		||||
  contract: CPMMBinaryContract | PseudoNumericContract
 | 
			
		||||
| 
						 | 
				
			
			@ -179,12 +178,7 @@ export function BuyPanel(props: {
 | 
			
		|||
  const initialProb = getProbability(contract)
 | 
			
		||||
  const isPseudoNumeric = contract.outcomeType === 'PSEUDO_NUMERIC'
 | 
			
		||||
 | 
			
		||||
  const windowSize = useWindowSize()
 | 
			
		||||
  const initialOutcome =
 | 
			
		||||
    windowSize.width && windowSize.width >= 1280 ? 'YES' : undefined
 | 
			
		||||
  const [outcome, setOutcome] = useState<'YES' | 'NO' | undefined>(
 | 
			
		||||
    initialOutcome
 | 
			
		||||
  )
 | 
			
		||||
  const [outcome, setOutcome] = useState<'YES' | 'NO' | undefined>()
 | 
			
		||||
  const [betAmount, setBetAmount] = useState<number | undefined>(10)
 | 
			
		||||
  const [error, setError] = useState<string | undefined>()
 | 
			
		||||
  const [isSubmitting, setIsSubmitting] = useState(false)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue
	
	Block a user