Skip to content

Commit

Permalink
feat: 优化 ref 取值
Browse files Browse the repository at this point in the history
  • Loading branch information
maxiaobo01 committed Aug 16, 2022
1 parent 01ecae9 commit 330ee38
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/multi/Editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ export const MultiEditorComp = React.forwardRef<MultiRefType, MultiEditorIProps>
if (path && files[path]) {
res = path;
}
handlePathChange(res);
handlePathChange(res, false);
}
loc && locModel(loc);
// 更新文件列表
Expand Down
5 changes: 4 additions & 1 deletion src/multi/hook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,10 @@ export function useEditor(

export const useVarRef = (param: any) => {
const varRef = useRef<any>(param);
varRef.current = useMemo(() => param, [param]);

useEffect(() => {
varRef.current = param;
}, [param]);

return varRef;
}

0 comments on commit 330ee38

Please sign in to comment.