use useIsClient
This commit is contained in:
parent
68dafa3684
commit
a267f3a476
|
@ -33,6 +33,7 @@ import EyeClose from '@/svgs/eye-close-line.svg'
|
||||||
import Info from './info'
|
import Info from './info'
|
||||||
import { useMe } from './me'
|
import { useMe } from './me'
|
||||||
import classNames from 'classnames'
|
import classNames from 'classnames'
|
||||||
|
import { useIsClient } from './use-client'
|
||||||
|
|
||||||
export class SessionRequiredError extends Error {
|
export class SessionRequiredError extends Error {
|
||||||
constructor () {
|
constructor () {
|
||||||
|
@ -455,6 +456,7 @@ function InputInner ({
|
||||||
const [field, meta, helpers] = noForm ? [{}, {}, {}] : useField(props)
|
const [field, meta, helpers] = noForm ? [{}, {}, {}] : useField(props)
|
||||||
const formik = noForm ? null : useFormikContext()
|
const formik = noForm ? null : useFormikContext()
|
||||||
const storageKeyPrefix = useContext(StorageKeyPrefixContext)
|
const storageKeyPrefix = useContext(StorageKeyPrefixContext)
|
||||||
|
const isClient = useIsClient()
|
||||||
|
|
||||||
const storageKey = storageKeyPrefix ? storageKeyPrefix + '-' + props.name : undefined
|
const storageKey = storageKeyPrefix ? storageKeyPrefix + '-' + props.name : undefined
|
||||||
|
|
||||||
|
@ -524,11 +526,6 @@ function InputInner ({
|
||||||
|
|
||||||
const remaining = maxLength && maxLength - (field.value || '').length
|
const remaining = maxLength && maxLength - (field.value || '').length
|
||||||
|
|
||||||
const [showClearButton, setShowClearButton] = useState(clear)
|
|
||||||
useEffect(() => {
|
|
||||||
setShowClearButton(clear && field.value && !props.readOnly)
|
|
||||||
}, [field.value, props.readOnly])
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<InputGroup hasValidation className={inputGroupClassName}>
|
<InputGroup hasValidation className={inputGroupClassName}>
|
||||||
|
@ -543,7 +540,7 @@ function InputInner ({
|
||||||
isInvalid={invalid}
|
isInvalid={invalid}
|
||||||
isValid={showValid && meta.initialValue !== meta.value && meta.touched && !meta.error}
|
isValid={showValid && meta.initialValue !== meta.value && meta.touched && !meta.error}
|
||||||
/>
|
/>
|
||||||
{showClearButton &&
|
{(isClient && clear && field.value && !props.readOnly) &&
|
||||||
<Button
|
<Button
|
||||||
variant={null}
|
variant={null}
|
||||||
onClick={(e) => {
|
onClick={(e) => {
|
||||||
|
|
Loading…
Reference in New Issue