Skip to content

Conversation

@hi-ogawa
Copy link
Owner

@hi-ogawa hi-ogawa commented Oct 16, 2025

Failed attempt of implementing Remix 3 hydrated component HMR:

  const ProxyComponent: Remix.Component = function (this) {
    listeners.add(() => this.update());

    // TODO: do we call "setup" for the first time and somehow patch it up later?
    // but new component's "render" function can only access new "setup"'s scope.
    // const data = manager.componentMap.get(name)!;
    // let result = data.Component.apply(this, [props]);
    // if (typeof result !== 'function') {
    //   return () => result;
    // }

    return (props) => {
      // TODO: this obviously remounts entire component since new `Component` has a new identity.
      const data = manager.componentMap.get(name)!;
      return jsx(data.Component as any, props);
    };
  };
  // For example, Vue SFC compiles "setup" part and "template" part as separate function,
  // then variables from "setup" are passed "template" render function arguments.
  // For Remix 3, state is entirely managed through closure scope,
  // so there's no way to reuse old "setup" state for new "render" function.

Copy link
Owner Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

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.

2 participants