polish: defensive hydration defaults on ZAMPP_DATA accessors
Guards against the brief window between app mount and the first data load completing — empty arrays render gracefully instead of throwing on .filter / .map.
This commit is contained in:
parent
24820e921e
commit
7da171cf1f
2 changed files with 4 additions and 4 deletions
|
|
@ -259,7 +259,7 @@ function _normRecorder(r) {
|
|||
}
|
||||
|
||||
function Recorders({ navigate, onNew }) {
|
||||
const [recorders, setRecorders] = React.useState(window.ZAMPP_DATA.RECORDERS);
|
||||
const [recorders, setRecorders] = React.useState(window.ZAMPP_DATA?.RECORDERS || []);
|
||||
|
||||
const refresh = React.useCallback(() => {
|
||||
window.ZAMPP_API.fetch('/recorders')
|
||||
|
|
@ -521,7 +521,7 @@ function Capture({ navigate }) {
|
|||
|
||||
/* ===== Monitors ===== */
|
||||
function Monitors({ navigate }) {
|
||||
const [recorders, setRecorders] = React.useState(window.ZAMPP_DATA.RECORDERS);
|
||||
const [recorders, setRecorders] = React.useState(window.ZAMPP_DATA?.RECORDERS || []);
|
||||
const [grid, setGrid] = React.useState(4);
|
||||
|
||||
React.useEffect(() => {
|
||||
|
|
|
|||
|
|
@ -42,8 +42,8 @@ function NewProjectModal({ onClose, onCreated }) {
|
|||
}
|
||||
|
||||
function Projects({ onOpenProject, navigate }) {
|
||||
const [projects, setProjects] = React.useState(window.ZAMPP_DATA.PROJECTS);
|
||||
const { ASSETS } = window.ZAMPP_DATA;
|
||||
const [projects, setProjects] = React.useState(window.ZAMPP_DATA?.PROJECTS || []);
|
||||
const ASSETS = window.ZAMPP_DATA?.ASSETS || [];
|
||||
const [search, setSearch] = React.useState('');
|
||||
const [view, setView] = React.useState('grid');
|
||||
const [showNew, setShowNew] = React.useState(false);
|
||||
|
|
|
|||
Loading…
Reference in a new issue