Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const SearchField = props => {
const { location, onChange, onFocus } = props;
const { value } = useFieldState('search_query');
const formApi = useFormApi();
const setValue = useCallback(
queryValue => {
// update search field
if (queryValue) {
formApi.setValue('search_query', queryValue);
}
// trigger the effects of clearing the field
if (typeof onChange === 'function') {
onChange('');
}
},
[formApi, onChange]
);
const LightningInvoiceInput = props => {
const { network, chain, field } = props
const intl = useIntl()
const fieldState = useFieldState(field)
const { value } = fieldState
let chainName = isLn(value, chain, network) ? 'lightning' : chain
if (network !== 'mainnet') {
chainName += ` (${network})`
}
const doValidate = useCallback(value => validate(intl, network, chain, value), [
chain,
intl,
network,
])
return (
<>
<textarea mask="{mask}"> {value && !fieldState.error && (</textarea>
const Autocomplete = props => {
const { setVisible, visible } = props;
const [queryResult, queryApi] = useQuery(PRODUCT_SEARCH);
const { data, error, loading } = queryResult;
const { resetState, runQuery, setLoading } = queryApi;
const { value } = useFieldState('search_query');
const valid = value && value.length > 2;
const classes = mergeClasses(defaultClasses, props.classes);
const rootClassName = visible ? classes.root_visible : classes.root_hidden;
let message = '';
if (error) {
message = 'An error occurred while fetching results.';
} else if (loading) {
message = 'Fetching results...';
} else if (!data) {
message = 'Search for a product';
} else if (!data.products.items.length) {
message = 'No results were found.';
} else {
message = `${data.products.items.length} items`;