Closed bangarang closed 3 months ago
The recent updates enhance the @flatfile/react
package by improving event listener management and integrating an accessToken
feature across several hooks. The useEvent
, useListener
, and usePlugin
functions now utilize the accessToken
from FlatfileContext
, ensuring that event handling and plugin functionalities are more responsive and context-aware. These changes aim to provide a more robust user experience by optimizing the flow of event listeners and maintaining synchronization with the context state.
Files | Change Summary |
---|---|
.changeset/fast-peaches-return.md |
Introduced a patch to improve flexibility in adding/modifying listeners in @flatfile/react , enhancing component interactivity. |
packages/react/src/hooks/useEvent.ts , packages/react/src/hooks/useListener.ts , packages/react/src/hooks/usePlugin.ts |
Added accessToken to context in all hooks, updating useEffect to improve event handling and ensure synchronization with context changes. |
sequenceDiagram
participant U as User
participant C as FlatfileContext
participant E as Event System
U->>C: Request access token
C-->>U: Provide access token
U->>E: Register event listener with access token
E->>E: Validate listener and access token
E-->>U: Listen for events
U->>E: Trigger event
E->>U: Notify event execution
Fixes a bug that doesn't re-attach linked listener code when changes to the Browser Driver happen. This happens when the
accessToken
is set after Space creation, so can cause a state where the listener is not attached to the client instance initially if it is not set inline.Example of test: