Compare commits

..
Author SHA1 Message Date
TJWater CI f5bcf28f7e fix(map): preserve hook order while data loads
Generic Container CI/CD / test-build-publish (push) Failing after 1m50s
Frontend CI/CD v2 / build-test-publish-and-deploy (push) Failing after 1m50s
2026-08-11 10:32:18 +08:00
5 changed files with 67 additions and 28 deletions
+9 -2
View File
@@ -16,9 +16,16 @@ interface LayerItem {
}
const LayerControl: React.FC = () => {
const map = useMap();
const data = useData();
if (!data) return;
if (!data) return null;
return <LayerControlContent data={data} />;
};
const LayerControlContent: React.FC<{
data: NonNullable<ReturnType<typeof useData>>;
}> = ({ data }) => {
const map = useMap();
const {
deckLayer,
isContourLayerAvailable,
+9 -5
View File
@@ -174,15 +174,19 @@ const hexToRgba = (hex: string) => {
: "rgba(0, 0, 0, 1)";
};
const StyleEditorPanel: React.FC<StyleEditorPanelProps> = ({
layerStyleStates,
setLayerStyleStates,
}) => {
const map = useMap();
const StyleEditorPanel: React.FC<StyleEditorPanelProps> = (props) => {
const data = useData();
if (!data) {
return <div>Loading...</div>; // 或其他占位符
}
return <StyleEditorPanelContent {...props} data={data} />;
};
const StyleEditorPanelContent: React.FC<
StyleEditorPanelProps & { data: NonNullable<ReturnType<typeof useData>> }
> = ({ layerStyleStates, setLayerStyleStates, data }) => {
const map = useMap();
const {
currentJunctionCalData,
currentPipeCalData,
+26 -14
View File
@@ -38,17 +38,37 @@ interface TimelineProps {
schemeType?: string;
}
const Timeline: React.FC<TimelineProps> = ({
const Timeline: React.FC<TimelineProps> = (props) => {
const data = useData();
if (
!data ||
data.setCurrentTime === undefined ||
data.currentTime === undefined ||
data.selectedDate === undefined ||
data.setSelectedDate === undefined
) {
return <div>Loading...</div>;
}
return <TimelineContent {...props} data={data} />;
};
const TimelineContent: React.FC<
TimelineProps & { data: NonNullable<ReturnType<typeof useData>> }
> = ({
schemeDate,
timeRange,
disableDateSelection = false,
schemeName = "",
schemeType = "burst_Analysis",
data,
}) => {
const data = useData();
if (!data) {
return <div>Loading...</div>; // 或其他占位符
}
const readyData = data as typeof data & {
currentTime: NonNullable<typeof data.currentTime>;
setCurrentTime: NonNullable<typeof data.setCurrentTime>;
selectedDate: NonNullable<typeof data.selectedDate>;
setSelectedDate: NonNullable<typeof data.setSelectedDate>;
};
const {
currentTime,
setCurrentTime,
@@ -58,15 +78,7 @@ const Timeline: React.FC<TimelineProps> = ({
setCurrentPipeCalData,
junctionText,
pipeText,
} = data;
if (
setCurrentTime === undefined ||
currentTime === undefined ||
selectedDate === undefined ||
setSelectedDate === undefined
) {
return <div>Loading...</div>; // 或其他占位符
}
} = readyData;
const { open } = useNotification();
const [isPlaying, setIsPlaying] = useState<boolean>(false);
+11 -3
View File
@@ -27,15 +27,23 @@ interface ToolbarProps {
queryType?: string; // 可选的查询类型参数
HistoryPanel?: React.FC<any>; // 可选的自定义历史数据面板
}
const Toolbar: React.FC<ToolbarProps> = ({
const Toolbar: React.FC<ToolbarProps> = (props) => {
const data = useData();
if (!data) return null;
return <ToolbarContent {...props} data={data} />;
};
const ToolbarContent: React.FC<
ToolbarProps & { data: NonNullable<ReturnType<typeof useData>> }
> = ({
hiddenButtons,
queryType,
HistoryPanel,
data,
}) => {
const map = useMap();
const data = useData();
const { open } = useNotification();
if (!data) return null;
const { currentTime, selectedDate, schemeName } = data;
const [activeTools, setActiveTools] = useState<string[]>([]);
const [highlightFeatures, setHighlightFeatures] = useState<Feature[]>([]);
@@ -59,13 +59,21 @@ interface TimelineProps {
schemeName?: string;
}
const Timeline: React.FC<TimelineProps> = ({
disableDateSelection = false,
}) => {
const Timeline: React.FC<TimelineProps> = (props) => {
const data = useData();
if (!data) {
return <div>Loading...</div>; // 或其他占位符
return <div>Loading...</div>;
}
return <TimelineContent {...props} data={data} />;
};
const TimelineContent: React.FC<
TimelineProps & { data: NonNullable<ReturnType<typeof useData>> }
> = ({
disableDateSelection = false,
data,
}) => {
const { open } = useNotification();
const {
predictionResults,