249export const getStaticProps = async ({
250 locale,
251 params,
252}: GetStaticPropsContext<RoutedQuery<'/org/[slug]'>>) => {253 if (!params) {
254 return { notFound: true }
255 }
124 <Button
125 className={classes.skipNext}
126 variant={'primary-icon'}
127 onClick={() => {128 if (!form.isValid()) return startShake()
129 setStep(stepNumber)
130 }}
82 validateInputOnBlur: true,
83 })
84
85 const submitHandler = () => { 86 if (!form.isValid()) return startShake()
87 UserSurveyAction.mutate(form.values)
88 }
347 })
348 return
349 }
350 return {351 label: t(item.attribute.tsKey, { ns: item.attribute.tsNs }),352 value: item.attribute.id,353 }354 }) ?? []
355 ),
356 ...otherOpt,
287 return
288 }
289
290 return {291 label: t(item.attribute.tsKey, { ns: item.attribute.tsNs }),292 value: item.attribute.id,293 }294 }) ?? []
295 ),
296 ...otherOpt,
Any code paths that do not have explicit returns will return undefined
.
It is recommended to replace any implicit dead-ends that return undefined
with a return null
statement.
As a convention, undefined
signals that an unexpected value has been produced as the
result of a logical error in the program.
A null
return, on the other hand, signals that the input to a function was incorrect,
or a value was 'not found'.
Having this distinction in code helps you figure out if something was caused because of a logical error, or malformed input to a function call.
function getUser(name) {
if (userExists(name)) {
return userDb.get(name);
}
// whoops! Implicit undefined return
}
function readFile(fileName) {
if (fs.existsSync(fileName)) {
return fs.readFileSync(fileName, 'utf-8');
}
return; // Implicit undefined return.
}
function getUser(name) {
if (userExists(name)) {
return userDb.get(name);
}
// `null` indicates there is no such user.
return null;
}
function readFile(fileName) {
if (fs.existsSync(fileName)) {
return fs.readFileSync(fileName, 'utf-8');
}
// `null` indicates there is no such file.
return null;
}