Skip to content

Conversation

clintandrewhall
Copy link
Contributor

@clintandrewhall clintandrewhall commented Oct 6, 2025

As titled. Adds a module-level singleton instance of the store and enhances the provider with useSyncExternalStore, (adds a Meta-maintained shim to support React 17).

I wrote this pretty quickly, and leveraged Gemini in some cases. Should be reviewed and revised with this in mind.

@elasticmachine
Copy link
Collaborator

💔 Build Failed

Failed CI Steps

History

@elasticmachine
Copy link
Collaborator

💚 Build Succeeded

"unified": "^9.2.2",
"unist-util-visit": "^2.0.3",
"url-parse": "^1.5.10",
"use-sync-external-store": "^1.6.0",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note to other reviewers: useSyncExternalStore is shipped with React starting from version 18.0. We need this shim for React 17 support

*/

import React, { createContext, useContext } from 'react';
import { useFlyoutManagerReducer } from './hooks';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

useFlyoutManagerReducer is now only used in tests. Do we need to keep it for any reason?

state,
...rest,
goToFlyout,
getHistoryItems: () => {
Copy link
Member

@tsullivan tsullivan Oct 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is selector logic, maybe a better architecture would be to move getHistoryItems to the store. Doing so would make it so that we don't need to destructure goToFlyout from the store on line 28.

Copy link
Member

@tsullivan tsullivan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you so much for working this out! Left a couple of comments

@clintandrewhall
Copy link
Contributor Author

Thanks @tsullivan I'll make the adjustments and open for review.

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.

4 participants