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

arrows don't re-render correctly #188

Open
mohdmujahithali opened this issue Mar 6, 2023 · 4 comments
Open

arrows don't re-render correctly #188

mohdmujahithali opened this issue Mar 6, 2023 · 4 comments

Comments

@mohdmujahithali
Copy link

mohdmujahithali commented Mar 6, 2023

After initial rending the arrow lines appear correctly as shown below

Screenshot 2023-03-07 003923

After opened the accordion of some portion, arrow lines get collapsed and shown as like below,

Screenshot 2023-03-07 003939

Also, while scrolling, arrow lines get collapsed and shown as like below,

Screenshot 2023-03-07 003952

I saw that there is an instance method "refreshScreen" need to be call, when the onscroll event happening. But there is clear documentation regarding that method how to call it? So, could you please provide the working example for "refreshScreen" instance method

Another example

after initial rendering,

Screenshot 2023-03-07 020814

after opened the accordion,

Screenshot 2023-03-07 020828

let me know the working example that how to use instance method "refreshScreen" here.

@pierpo
Copy link
Owner

pierpo commented Mar 7, 2023

Hi!

Thank you for the detailed issue.

Can you try calling refreshScreen when your screen moves?
For example, if you collapse/uncollapse an accordion, then call refreshScreen afterwards.

const archerRef = useRef()

useEffect(() => {
  archerRef.refreshScreen()
}, [isOpen])

return <ArcherContainer ref={archerRef}>...</ArcherContainer>

@mohdmujahithali
Copy link
Author

mohdmujahithali commented Mar 7, 2023

@pierpo

I declared reference as below,

const archerRef = useRef();

Then I got the below error

image

So, I declared reference with null as below,

const archerRef = useRef(null);

Then I got the error for "refreshScreen" function call

image

Does we need to import anything for "refreshScreen" method?

image

image

image

@pierpo
Copy link
Owner

pierpo commented Mar 7, 2023

This is only a type error, I think it would work at runtime.

To solve your error:

// (note: this import does not look good indeed, it needs a fix on the lib's side)
import { ArcherContainerHandle } from 'react-archer/lib/ArcherContainer/ArcherContainer.types';

// ...
const archerRef = useRef<ArcherContainerHandle>(null);

The method does exist, it's only your typing that is wrong 😉

@lucfranken
Copy link

lucfranken commented Nov 17, 2023

In case one is searching, the example above is in general correct but your state var might changes earlier in the process causing undefined variable issues.

const archerRef = useRef<ArcherContainerHandle>(null);
  import { ArcherContainerHandle } from 'react-archer/lib/ArcherContainer/ArcherContainer.types';

    useEffect(() => {
        if (archerRef?.current) {
            archerRef.current.refreshScreen()
        }
    }, [zoomLevel]);

Checking for the availability of the ref might help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants