201 rightSection: { display: 'none' },
202 }}
203 filter={(value, item) =>
204 item &&205 item.label &&206 (item.label.toLowerCase().includes((value || '').toLowerCase().trim()) ||
207 item.tsKey.toLowerCase().includes((value || '').toLowerCase().trim()))
208 }
244 api.geo.geoByPlaceId.useQuery(locationSearch, {
245 enabled: locationSearch !== '',
246 onSuccess: ({ result }) => {
247 if (result && result.city && result.govDist && result.country)248 form.setValues({ location: { city: result.city, govDist: result.govDist, country: result.country } })
249 },
250 })
61 >{`Edit ${badgeType === 'organization-leadership' ? 'Organization Leadership' : 'Service Focus'} Badges`}</Title>
62 <Chip.Group multiple control={form.control} name='badges'>
63 <Stack spacing={12}>
64 {badgeOptions &&65 badgeOptions.map(({ id, tsKey, tsNs, icon }) => (66 <Chip.Item key={id} value={id}>67 {`${icon} ${t(tsKey, { ns: tsNs })}`}68 </Chip.Item>69 ))}70 </Stack>
71 </Chip.Group>
72 <Button
74 onChange(updatedValue)
75 } else {
76 onChange(null)
77 form && form.setError(name, { message: 'Invalid time range' }) 78 }
79 // eslint-disable-next-line react-hooks/exhaustive-deps
80 }, [openValue, closeValue])
The optional chaining operator can be used to perform null checks before accessing a property, or calling a function.
Using &&
for this purpose is no longer required.
function getUsernameFromId(id: number): string | undefined {
const user = db.getUser(id)
return user && user.name
}
someFunc && someFunc()
// ^~~~ not necessary
maybeArray && maybeArray[index]
// ^~~~ not necessary
function getUsernameFromId(id: number): string | undefined {
const user = db.getUser(id)
return user?.name
}
someFunc?.()
maybeArray?.[index]