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 }) {
|
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(() => {
|
const refresh = React.useCallback(() => {
|
||||||
window.ZAMPP_API.fetch('/recorders')
|
window.ZAMPP_API.fetch('/recorders')
|
||||||
|
|
@ -521,7 +521,7 @@ function Capture({ navigate }) {
|
||||||
|
|
||||||
/* ===== Monitors ===== */
|
/* ===== Monitors ===== */
|
||||||
function Monitors({ navigate }) {
|
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);
|
const [grid, setGrid] = React.useState(4);
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
|
|
|
||||||
|
|
@ -42,8 +42,8 @@ function NewProjectModal({ onClose, onCreated }) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function Projects({ onOpenProject, navigate }) {
|
function Projects({ onOpenProject, navigate }) {
|
||||||
const [projects, setProjects] = React.useState(window.ZAMPP_DATA.PROJECTS);
|
const [projects, setProjects] = React.useState(window.ZAMPP_DATA?.PROJECTS || []);
|
||||||
const { ASSETS } = window.ZAMPP_DATA;
|
const ASSETS = window.ZAMPP_DATA?.ASSETS || [];
|
||||||
const [search, setSearch] = React.useState('');
|
const [search, setSearch] = React.useState('');
|
||||||
const [view, setView] = React.useState('grid');
|
const [view, setView] = React.useState('grid');
|
||||||
const [showNew, setShowNew] = React.useState(false);
|
const [showNew, setShowNew] = React.useState(false);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue