-
-
Notifications
You must be signed in to change notification settings - Fork 7k
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
Onchange function getting triggered on each and every component render #3014
Comments
@CV1928 yes currently |
I don't think we should be doing that just yet. It'll slow down the update loop, especially when we rewrite the |
@dwelle didn't get you. For host triggering |
Of course it shouldn't. What I'm pointing out that it'll impact perf of:
If the change resolving was free, then I'd say let's do it. That said, my intuition may be off, so we should measure it — but we should measure the soon-to-be resolver, not what we do right now (summing up element versions). |
AFAIU |
@ad1992 Any tentative time by when you can do this change. Caching also is a problem. I am having n instances of excalidraw on my webpage. Maintaining cached state for all of them is actually a headache. Is there anything else I can do here? |
Completely optimizing |
@ad1992 @dwelle Suppose I am saving excalidraw 'elements and appState' in Database and on page refresh, I am fetching that state to updateScene in useEffect. How do I make sure that the 'Excali instance is loaded' and saved in 'excalidrawRef' before I invoke updateScene Api of Excali?
By the time excalidrawRef is updated, useEffect due to value has already been executed. And Since excalidrawRef.current is null at that time, It wouldn't update the scene. Now even if excalidrawRef.current is updated after the component returns JSX, it wouldn't again go to useEffect again. So scene couldn't be updated at all. |
You can do two things:
|
I'm having trouble with this as well, especially if the elements get set back to []. Is there a more robust way to expose versioning information? |
i do have the same problem
` |
Do we have any updates on this issue? |
Hey,
I am using react excalidraw package. I am trying to do collaboration feature for 2 people. Both the people will share the below component. Let's say person A and person B. If person A changes anything in the whiteboard, it will inturn trigger onChange function, which will send data over socket and will be recieved by person B in the useEffect where I am calling updateScene API.
The only problem is I am running into infinite loop because onChange function is getting triggered by itself on each and every component render. Am I missing something?
This is what my component returns :
This is the onChange function :
This is my useEffect for updating elements upon receiving elements prop :
The text was updated successfully, but these errors were encountered: