refactor: repartition server-side and client-side code
This commit is contained in:
23
app/.client/components/sidebar/HistorySwitch.tsx
Normal file
23
app/.client/components/sidebar/HistorySwitch.tsx
Normal file
@@ -0,0 +1,23 @@
|
||||
import { memo, useEffect, useState } from 'react';
|
||||
import { IconButton } from '~/.client/components/ui/IconButton';
|
||||
import { toggleSidebar } from '~/.client/stores/sidebar';
|
||||
|
||||
interface HistorySwitchProps {
|
||||
className?: string;
|
||||
}
|
||||
|
||||
export const HistorySwitch = memo(({ className }: HistorySwitchProps) => {
|
||||
const [domLoaded, setDomLoaded] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
setDomLoaded(true);
|
||||
}, []);
|
||||
|
||||
return (
|
||||
domLoaded && (
|
||||
<IconButton className={className} title="查看历史" onClick={toggleSidebar}>
|
||||
<div className="i-mingcute:history-line text-xl"></div>
|
||||
</IconButton>
|
||||
)
|
||||
);
|
||||
});
|
||||
Reference in New Issue
Block a user