less hasty fix preventing localStorage call on SSR
This commit is contained in:
		
							parent
							
								
									143f5a3463
								
							
						
					
					
						commit
						7aa294b57e
					
				@ -127,10 +127,10 @@ function InputInner ({
 | 
				
			|||||||
    if (overrideValue) {
 | 
					    if (overrideValue) {
 | 
				
			||||||
      helpers.setValue(overrideValue)
 | 
					      helpers.setValue(overrideValue)
 | 
				
			||||||
      if (storageKey) {
 | 
					      if (storageKey) {
 | 
				
			||||||
        localStorage?.setItem(storageKey, overrideValue)
 | 
					        localStorage.setItem(storageKey, overrideValue)
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    } else if (storageKey) {
 | 
					    } else if (storageKey) {
 | 
				
			||||||
      const draft = localStorage?.getItem(storageKey)
 | 
					      const draft = localStorage.getItem(storageKey)
 | 
				
			||||||
      if (draft) {
 | 
					      if (draft) {
 | 
				
			||||||
        // for some reason we have to turn off validation to get formik to
 | 
					        // for some reason we have to turn off validation to get formik to
 | 
				
			||||||
        // not assume this is invalid
 | 
					        // not assume this is invalid
 | 
				
			||||||
 | 
				
			|||||||
@ -6,7 +6,7 @@ import { COMMENTS } from '../fragments/comments'
 | 
				
			|||||||
import { useMe } from './me'
 | 
					import { useMe } from './me'
 | 
				
			||||||
import ActionTooltip from './action-tooltip'
 | 
					import ActionTooltip from './action-tooltip'
 | 
				
			||||||
import TextareaAutosize from 'react-textarea-autosize'
 | 
					import TextareaAutosize from 'react-textarea-autosize'
 | 
				
			||||||
import { useLayoutEffect, useState } from 'react'
 | 
					import { useEffect, useState } from 'react'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export const CommentSchema = Yup.object({
 | 
					export const CommentSchema = Yup.object({
 | 
				
			||||||
  text: Yup.string().required('required').trim()
 | 
					  text: Yup.string().required('required').trim()
 | 
				
			||||||
@ -16,7 +16,7 @@ export default function Reply ({ parentId, onSuccess, replyOpen }) {
 | 
				
			|||||||
  const [reply, setReply] = useState(replyOpen)
 | 
					  const [reply, setReply] = useState(replyOpen)
 | 
				
			||||||
  const me = useMe()
 | 
					  const me = useMe()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  useLayoutEffect(() => {
 | 
					  useEffect(() => {
 | 
				
			||||||
    setReply(replyOpen || !!localStorage.getItem('reply-' + parentId + '-' + 'text'))
 | 
					    setReply(replyOpen || !!localStorage.getItem('reply-' + parentId + '-' + 'text'))
 | 
				
			||||||
  }, [])
 | 
					  }, [])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user