fix(TradingSimulation): 修复 React Hooks 调用顺序错误
提取 JSX 中直接调用的 useColorModeValue 到组件顶部,避免 Hooks 顺序不一致。 修改内容: - 在第 95 行添加 contentTextColor 常量 - 替换第 350 行 Heading 中的内联 Hook 调用 - 替换第 361 行 Text 中的内联 Hook 调用 修复警告:React has detected a change in the order of Hooks called by TradingSimulation 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -92,6 +92,7 @@ export default function TradingSimulation() {
|
|||||||
const xAxisLabelColor = useColorModeValue('#718096', '#A0AEC0');
|
const xAxisLabelColor = useColorModeValue('#718096', '#A0AEC0');
|
||||||
const yAxisLabelColor = useColorModeValue('#718096', '#A0AEC0');
|
const yAxisLabelColor = useColorModeValue('#718096', '#A0AEC0');
|
||||||
const gridBorderColor = useColorModeValue('#E2E8F0', '#4A5568');
|
const gridBorderColor = useColorModeValue('#E2E8F0', '#4A5568');
|
||||||
|
const contentTextColor = useColorModeValue('gray.700', 'white');
|
||||||
|
|
||||||
// ========== 2. 所有 useEffect 也必须在条件返回之前 ==========
|
// ========== 2. 所有 useEffect 也必须在条件返回之前 ==========
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -346,7 +347,7 @@ export default function TradingSimulation() {
|
|||||||
<VStack spacing={6} align="stretch">
|
<VStack spacing={6} align="stretch">
|
||||||
{/* 账户概览统计 */}
|
{/* 账户概览统计 */}
|
||||||
<Box>
|
<Box>
|
||||||
<Heading size="lg" mb={4} color={useColorModeValue('gray.700', 'white')}>
|
<Heading size="lg" mb={4} color={contentTextColor}>
|
||||||
📊 账户统计分析
|
📊 账户统计分析
|
||||||
</Heading>
|
</Heading>
|
||||||
<AccountOverview account={account} tradingEvents={tradingEvents} />
|
<AccountOverview account={account} tradingEvents={tradingEvents} />
|
||||||
@@ -357,7 +358,7 @@ export default function TradingSimulation() {
|
|||||||
<Card>
|
<Card>
|
||||||
<CardHeader>
|
<CardHeader>
|
||||||
<HStack justify="space-between">
|
<HStack justify="space-between">
|
||||||
<Text fontSize="lg" fontWeight="bold" color={useColorModeValue('gray.700', 'white')}>
|
<Text fontSize="lg" fontWeight="bold" color={contentTextColor}>
|
||||||
📈 资产走势分析
|
📈 资产走势分析
|
||||||
</Text>
|
</Text>
|
||||||
<Badge colorScheme="purple" variant="outline">
|
<Badge colorScheme="purple" variant="outline">
|
||||||
|
|||||||
Reference in New Issue
Block a user