Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into beta-releases
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Sep 16, 2024
2 parents 934bdc0 + f15e88f commit 88054a2
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 15 deletions.
2 changes: 1 addition & 1 deletion THIRD-PARTY-NOTICES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
The following third-party software is used by and included in **Mongodb Compass**.
This document was automatically generated on Sun Sep 15 2024.
This document was automatically generated on Mon Sep 16 2024.

## List of dependencies

Expand Down
2 changes: 1 addition & 1 deletion docs/tracking-plan.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

# Compass Tracking Plan

Generated on Sun, Sep 15, 2024 at 03:14 AM
Generated on Mon, Sep 16, 2024 at 08:22 AM

## Table of Contents

Expand Down
32 changes: 19 additions & 13 deletions packages/compass-connections/src/connection-info-provider.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { createContext, useContext } from 'react';
import React, { createContext, useContext, useState } from 'react';
import type { ConnectionInfo } from '@mongodb-js/connection-info';
import {
createServiceLocator,
Expand Down Expand Up @@ -88,19 +88,25 @@ export const useConnectionInfoAccess = (): ConnectionInfoAccess => {
// This is stable in all environments
// eslint-disable-next-line react-hooks/rules-of-hooks
const connectionInfoRef = useConnectionInfoRefForId(connectionId);
return {
getCurrentConnectionInfo() {
if (!connectionInfoRef.current) {
if (process.env.NODE_ENV !== 'test') {
throw new Error(
'Could not find the current ConnectionInfo. Did you forget to setup the ConnectionInfoContext?'
);
// eslint-disable-next-line react-hooks/rules-of-hooks
const [access] = useState(() => {
// Return the function from useState to make sure the value doesn't change
// when component re-renders
return {
getCurrentConnectionInfo() {
if (!connectionInfoRef.current) {
if (process.env.NODE_ENV !== 'test') {
throw new Error(
'Could not find the current ConnectionInfo. Did you forget to setup the ConnectionInfoContext?'
);
}
return TEST_CONNECTION_INFO;
}
return TEST_CONNECTION_INFO;
}
return connectionInfoRef.current;
},
};
return connectionInfoRef.current;
},
};
});
return access;
};
export const connectionInfoAccessLocator = createServiceLocator(
useConnectionInfoAccess,
Expand Down

0 comments on commit 88054a2

Please sign in to comment.