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

React | HTML Components: Adding component dependency to useImperativeHandle #477

Merged
merged 1 commit into from
Nov 5, 2024

Conversation

rokotyan
Copy link
Contributor

Fixes #472

Updated dependencies for the useImperativeHandle hook to include the component in its dependency array. This ensures that references to the component are correctly updated whenever it changes, leading to improved synchronization and reliability in the component's behavior.

…iveHandle`

Updated dependencies for the `useImperativeHandle` hook to include the `component` in its dependency array. This ensures that references to the component are correctly updated whenever it changes, leading to improved synchronization and reliability in the component's behavior.

f5#472
@lee00678
Copy link
Collaborator

@rokotyan maybe I'm not testing this currently, but the mapRef in the leaflet-map example https://github.com/f5/unovis/blob/main/packages/shared/examples/advanced-leaflet-map/advanced-leaflet-map.tsx#L23-L32 are still always null for both events.

@rokotyan
Copy link
Contributor Author

@lee00678 How are you testing it? I quickly tried it on my end with the dev app, and it worked.

@lee00678
Copy link
Collaborator

@lee00678 How are you testing it? I quickly tried it on my end with the dev app, and it worked.

I tried it with the leaflet-map gallery example. I just added console.log in those two click functions here. Sees to me myRef.current is always null.

@rokotyan
Copy link
Contributor Author

image @lee00678 Worked on my end. Have you built @unovis/react before trying?

@lee00678
Copy link
Collaborator

lee00678 commented Oct 30, 2024

@lee00678 Worked on my end. Have you built @unovis/react before trying?

That's odd. I did npm run install:clean. I also just tried to build react separately by doing npm run build:react, still no luck. The code changes are there.

@lee00678
Copy link
Collaborator

@rokotyan I can't seem to get this fix working.

I added a console.log inside react/src/html-component/leaflet-map/index.tsx to ensure react was built.
Screenshot 2024-10-31 at 12 47 39 PM

My myRef.current is always null.
Screenshot 2024-10-31 at 12 47 26 PM
Screenshot 2024-10-31 at 12 46 57 PM

@rokotyan
Copy link
Contributor Author

rokotyan commented Oct 31, 2024

@lee00678 And what happens when you click on current? It doesn't seem to be null
image

@lee00678
Copy link
Collaborator

lee00678 commented Nov 5, 2024

@lee00678 And what happens when you click on current? It doesn't seem to be null

You are right. I thought it's returning an empty object. The component is inside. Sorry.

@lee00678 lee00678 merged commit 2fc7e96 into f5:main Nov 5, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ref undefined
2 participants