Browse Source

Making SearchablePicker not dependent on Formik

master
GabrielTrettel 3 years ago
parent
commit
54522a45c8
  1. 15
      src/app/components/SearchablePicker.js
  2. 2
      src/app/config/dimensions.js

15
src/app/components/SearchablePicker.js

@ -61,15 +61,22 @@ function SearchablePicker({
formPlaceholder,
searchPlaceholder,
name,
setSelected,
nothingToShow = "Não encontramos nada com esse termo",
marginRight = 2,
marginLeft = 16,
}) {
const { values, setFieldValue, errors, touched } = useFormikContext();
const [value, setValue] = useState(values[name]);
const { values, setFieldValue, errors, touched } = name ? useFormikContext() : [1,1,1,1];
const [value, setValue] = useState(name ? values[name] : "");
useEffect(() => {
setFieldValue(name, value, true);
if (name)
setFieldValue(name, value, true);
else
setSelected(value)
}, [value]);
return (
@ -97,7 +104,7 @@ function SearchablePicker({
/>
</Shadow>
<ErrorMessage error={errors[name]} visible={touched[name]} />
{name && (<ErrorMessage error={errors[name]} visible={touched[name]} />)}
</View>
);
}

2
src/app/config/dimensions.js

@ -5,7 +5,7 @@ const screen_height = Dimensions.get("window").height;
const dimensions = {
text: {
header: 26,
header: 24,
secondary: 18,
default: 16,
tertiary: 14,

Loading…
Cancel
Save