less hasty fix preventing localStorage call on SSR

This commit is contained in:
keyan 2022-01-08 09:31:37 -06:00
parent 143f5a3463
commit 7aa294b57e
2 changed files with 4 additions and 4 deletions

View File

@ -127,10 +127,10 @@ function InputInner ({
if (overrideValue) {
helpers.setValue(overrideValue)
if (storageKey) {
localStorage?.setItem(storageKey, overrideValue)
localStorage.setItem(storageKey, overrideValue)
}
} else if (storageKey) {
const draft = localStorage?.getItem(storageKey)
const draft = localStorage.getItem(storageKey)
if (draft) {
// for some reason we have to turn off validation to get formik to
// not assume this is invalid

View File

@ -6,7 +6,7 @@ import { COMMENTS } from '../fragments/comments'
import { useMe } from './me'
import ActionTooltip from './action-tooltip'
import TextareaAutosize from 'react-textarea-autosize'
import { useLayoutEffect, useState } from 'react'
import { useEffect, useState } from 'react'
export const CommentSchema = Yup.object({
text: Yup.string().required('required').trim()
@ -16,7 +16,7 @@ export default function Reply ({ parentId, onSuccess, replyOpen }) {
const [reply, setReply] = useState(replyOpen)
const me = useMe()
useLayoutEffect(() => {
useEffect(() => {
setReply(replyOpen || !!localStorage.getItem('reply-' + parentId + '-' + 'text'))
}, [])