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 yAxisLabelColor = useColorModeValue('#718096', '#A0AEC0');
|
||||
const gridBorderColor = useColorModeValue('#E2E8F0', '#4A5568');
|
||||
const contentTextColor = useColorModeValue('gray.700', 'white');
|
||||
|
||||
// ========== 2. 所有 useEffect 也必须在条件返回之前 ==========
|
||||
useEffect(() => {
|
||||
@@ -346,7 +347,7 @@ export default function TradingSimulation() {
|
||||
<VStack spacing={6} align="stretch">
|
||||
{/* 账户概览统计 */}
|
||||
<Box>
|
||||
<Heading size="lg" mb={4} color={useColorModeValue('gray.700', 'white')}>
|
||||
<Heading size="lg" mb={4} color={contentTextColor}>
|
||||
📊 账户统计分析
|
||||
</Heading>
|
||||
<AccountOverview account={account} tradingEvents={tradingEvents} />
|
||||
@@ -357,7 +358,7 @@ export default function TradingSimulation() {
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<HStack justify="space-between">
|
||||
<Text fontSize="lg" fontWeight="bold" color={useColorModeValue('gray.700', 'white')}>
|
||||
<Text fontSize="lg" fontWeight="bold" color={contentTextColor}>
|
||||
📈 资产走势分析
|
||||
</Text>
|
||||
<Badge colorScheme="purple" variant="outline">
|
||||
|
||||
Reference in New Issue
Block a user