Skip to content
This repository was archived by the owner on Jul 24, 2025. It is now read-only.

Conversation

@ArnaudBarre
Copy link
Member

@ArnaudBarre ArnaudBarre commented Jan 26, 2024

__beforePerformReactRefresh & __getReactRefreshIgnoredExports will not be part of semver until Remiix on Vite is stable (and without Fast Refresh related stuff being vendored).

I'll do the same on the Babel plugin once I've got some positif feedback from @pcattori

@ArnaudBarre ArnaudBarre self-assigned this Jan 26, 2024

const enqueueUpdate = debounce(performReactRefresh, 16);
const enqueueUpdate = debounce(() => {
window.__beforePerformReactRefresh?.();
Copy link
Member

Choose a reason for hiding this comment

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

I guess it'd nice to support registering multiple functions.
For example:

const hooks = []
window.__registerBeforePerformReactRefresh = (cb) => {
  hooks.push(cb)
}

// run in enqueueUpdate
hooks.forEach(hook => hook())

// framework code

window.__registerBeforePerformReactRefresh(() => {
  // do something that's needed
})

Another way to expose this functionality is to use an exported function:

import { registerBeforePerformReactRefreshHook } from '/@react-refresh-api'

registerBeforePerformReactRefreshHook(() => {
  // do something that's needed for that framework
})

I'm not sure which is better.

Copy link
Member Author

Choose a reason for hiding this comment

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

This made me remind that Remix need this to be async
The second option is cleaner, but requires the remix client to passe through Vite pipeline or to handle base path, and I'm not sure it's the case for now

Copy link
Member

@sapphi-red sapphi-red left a comment

Choose a reason for hiding this comment

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

If this interface meets the needs of the remix, it looks good to me.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants