Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] 无法获取最新的ref #289

Open
1 task
canvascat opened this issue Oct 16, 2024 · 0 comments
Open
1 task

[BUG] 无法获取最新的ref #289

canvascat opened this issue Oct 16, 2024 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@canvascat
Copy link

Basic Info

打开popup后,调用方法获取ref,返回的popupRef.current不是最新的,全是null
image

useImperativeHandle(ref, () => maskingRef.current!);

建议调整写法:

    useImperativeHandle(
        ref,
        () => ({
            get dom() {
                return maskingRef.current?.dom ?? null;
            },
            get content() {
                return maskingRef.current?.content ?? null;
            },
            get mask() {
                return maskingRef.current?.mask ?? null;
            },
            setCloseScene(scene: string) {
                maskingRef.current?.setCloseScene(scene);
            },
        }),
        [],
    );

类似的问题还有很多:

useImperativeHandle(ref, () => ({
dom: domRef.current,
}));

useImperativeHandle(ref, () => ({
dom: domRef.current,
}));

.....

@adaex adaex added the bug Something isn't working label Dec 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants