Skip to content

React useProcedure hook not compatible with spacetimedb/tanstack #4957

@ferntheplant

Description

@ferntheplant

We had to do vile things to get it working

export default App() {
  const connectionBuilderTanstack = useMemo(() => {
    return DbConnection.builder()
      .withUri(HOST)
      .withDatabaseName(DB_NAME)
      .withToken(token ?? undefined)
      .onConnect(onConnect)
      .onDisconnect(onDisconnect)
      .onConnectError(onConnectError);
  }, [token]);
  const connectionBuilderReact = useMemo(() => {
    return DbConnection.builder()
      .withUri(HOST)
      .withDatabaseName(DB_NAME)
      .withToken(token ?? undefined)
      .onConnect(onConnect)
      .onDisconnect(onDisconnect)
      .onConnectError(onConnectError);
  }, [token]);

  return (
    <SpacetimeDBProviderTanstack connectionBuilder={connectionBuilderTanstack}>
      <SpacetimeDBProviderReact connectionBuilder={connectionBuilderReact}>
      <RouterProvider router={router} />
      <Toaster />
    </SpacetimeDBProviderReact>
    </SpacetimeDBProviderTanstack>
  );
}

Solution: either export a version useProcedure as part of spacetimedb/tanstack that is hooked up to the tanstack provider OR unify the spacetimedb/react and spacetimedb/tanstack providers

Related: Pull #4752 and Issue #4751

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions