return <Box height="100%" p={0.5} width="100%" borderRadius="8px" sx={{bgcolor: theme =>…
- User
return <Box height="100%" p={0.5} width="100%" borderRadius="8px" sx={{bgcolor: theme => theme.palette.mode === "dark" ? "#0d0d0d" : "#fff"}}> <FormControl sx={{mb: 1, height: 24, width: 43, px: 0, backgroundColor: theme => theme.palette.grey[100], color: "#191919", padding: "0", borderRadius: "8px", "& .MuiSelect-select": {paddingY: 0.55, pl: 1.3, overflow: "inherit"}, "& svg": {right: 2}, "& fieldset": {border: "none", pr: 0}, "& path": {color: (theme) => theme.palette.white.contrastText, pr: 0}, }}> <Select sx={{fontSize: 11, color: theme => theme.palette.white.contrastText}} value={interval} onChange={(e) => handleIntervalChange(e, windowChart)}> <MenuItem sx={{fontSize: 11}} value="1m">1м <MenuItem sx={{fontSize: 11}} value="5m">5м <MenuItem sx={{fontSize: 11}} value="15m">15м <MenuItem sx={{fontSize: 11}} value="1h">1ч <MenuItem sx={{fontSize: 11}} value="4h">4ч <MenuItem sx={{fontSize: 11}} value="1d">1д <MenuItem sx={{fontSize: 11}} value="1w">1н
code<SettingsToolsMenu settingsTools={settingsTools} toggleVisibility={toggleVisibility} chartYAxisType={chartYAxisType} setChartYAxisType={setChartYAxisType} /> </Grid> { symbol ? <KLineChart symbol={symbol} windowChart={windowChart} interval={interval} settingsTools={settingsTools} chartYAxisType={chartYAxisType} /> : <Box width="100%" height="88%" display="flex" alignItems="center" justifyContent="center"> <Typography fontSize={28} color="#9999994d"> Выберите монету</Typography> </Box> }; };
при изменении symbol заново удалять и заново перерисовывать
- Assistant
To re-render the
<KLineChart />component when thesymbolprop changes, you can add a key prop to the component and update it when thesymbolchanges. This will cause React to unmount the old component and mount a new one.Here's an example of how you can implement this:
javascriptreturn ( <Box height="100%" p={0.5} width="100%" borderRadius="8px" sx={{bgcolor: theme => theme.palette.mode === "dark" ? "#0d0d0d" : "#fff"}}> <Grid display="flex" justifyContent="space-between" > {/* Rest of the code */} </Grid> {symbol ? ( <KLineChart key={symbol} symbol={symbol} windowChart={windowChart} interval={interval} settingsTools={settingsTools} chartYAxisType={chartYAxisType} /> ) : ( <Box width="100%" height="88%" display="flex" alignItems="center" justifyContent="center"> <Typography fontSize={28} color="#9999994d"> Выберите монету</Typography> </Box> )} </Box> );