改进 Minimap 组件的 ref 赋值逻辑,支持回调函数和 ref 对象两种形式
This commit is contained in:
@@ -18,9 +18,17 @@ export function Minimap({
|
||||
stageClassName?: string;
|
||||
viewportClassName?: string;
|
||||
}) {
|
||||
const assignMinimapRef = (element: HTMLButtonElement | null) => {
|
||||
if (typeof minimapRef === 'function') {
|
||||
minimapRef(element);
|
||||
} else if (minimapRef) {
|
||||
minimapRef.current = element;
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<button
|
||||
ref={minimapRef}
|
||||
ref={assignMinimapRef}
|
||||
type="button"
|
||||
className={`genarrative-image-canvas__minimap ${className}`.trim()}
|
||||
aria-label="画布小地图"
|
||||
|
||||
Reference in New Issue
Block a user