Skip to content
This repository has been archived by the owner on Nov 29, 2023. It is now read-only.

Commit

Permalink
Test useeffec on props 3
Browse files Browse the repository at this point in the history
  • Loading branch information
guerrato committed Feb 18, 2022
1 parent 35e3be8 commit d86b578
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
11 changes: 8 additions & 3 deletions src/lib/components/inputs/basic/Input.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react'
import React, { useEffect, useState } from 'react'
import { isEmpty } from '../../../helpers/general'
import { InputProps } from './shared'
import { Checkbox } from '../Checkbox'
Expand Down Expand Up @@ -31,7 +31,6 @@ const InputVariant: React.FC<InputProps> = (props) => {
}

export const Input = (props: InputProps) => {
verifyRequiredProps(props)
const theme = useTheme()

const styles = {
Expand Down Expand Up @@ -82,7 +81,13 @@ export const Input = (props: InputProps) => {
}
}

const inputProps: InputProps = { ...props, inputStyles: styles }
verifyRequiredProps(props)

const [inputProps, setInputProps] = useState<InputProps>({ ...props, inputStyles: styles })

useEffect(() => {
setInputProps({ ...props, inputStyles: styles })
}, [props])

return (
<FormGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/inputs/basic/text/Text.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const Text = (props: InputProps) => {
}, [validationResponse])

useEffect(() => {
console.log({log: 'roso', props})
console.log({ log: 'roso', props })
setValidationResponse(props.value)
}, [props])

Expand Down

0 comments on commit d86b578

Please sign in to comment.