76 }
77 }, [dznInstances]);
78
79 const solverOptions = useMemo(() => { 80 if (solvers) {
81 return solvers.map((solver) => {
82 return { label: solver.name, value: solver.id };
65 }
66 }, [mznInstances]);
67
68 const dznOptions = useMemo(() => { 69 if (dznInstances) {
70 return dznInstances.map((instance) => {
71 return {
54 const [flagTimeout, setFlagTimeout] = useState(60);
55 const [flagMemory, setFlagMemory] = useState(512);
56
57 const mznOptions = useMemo(() => { 58 if (mznInstances) {
59 return mznInstances.map((instance) => {
60 return {
118 tmp[tmp.findIndex((u) => u.id === user.id)].runs = tmp[
119 tmp.findIndex((u) => u.id === user.id)
120 ].runs.filter((value) => value.id != run.id);
121 return tmp;122 });
123 }
124 }
72 const tmp = [...v];
73 tmp[tmp.findIndex((u) => u.id === user.id)].sys_admin =
74 user.sys_admin !== null ? null : { id: 2, user: "a" };
75 return tmp; 76 });
77 }
78 }
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;
}