Skip to content

Commit 88054a2

Browse files
Merge remote-tracking branch 'origin/main' into beta-releases
2 parents 934bdc0 + f15e88f commit 88054a2

File tree

3 files changed

+21
-15
lines changed

3 files changed

+21
-15
lines changed

THIRD-PARTY-NOTICES.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
The following third-party software is used by and included in **Mongodb Compass**.
2-
This document was automatically generated on Sun Sep 15 2024.
2+
This document was automatically generated on Mon Sep 16 2024.
33

44
## List of dependencies
55

docs/tracking-plan.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
# Compass Tracking Plan
33

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

66
## Table of Contents
77

packages/compass-connections/src/connection-info-provider.tsx

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { createContext, useContext } from 'react';
1+
import React, { createContext, useContext, useState } from 'react';
22
import type { ConnectionInfo } from '@mongodb-js/connection-info';
33
import {
44
createServiceLocator,
@@ -88,19 +88,25 @@ export const useConnectionInfoAccess = (): ConnectionInfoAccess => {
8888
// This is stable in all environments
8989
// eslint-disable-next-line react-hooks/rules-of-hooks
9090
const connectionInfoRef = useConnectionInfoRefForId(connectionId);
91-
return {
92-
getCurrentConnectionInfo() {
93-
if (!connectionInfoRef.current) {
94-
if (process.env.NODE_ENV !== 'test') {
95-
throw new Error(
96-
'Could not find the current ConnectionInfo. Did you forget to setup the ConnectionInfoContext?'
97-
);
91+
// eslint-disable-next-line react-hooks/rules-of-hooks
92+
const [access] = useState(() => {
93+
// Return the function from useState to make sure the value doesn't change
94+
// when component re-renders
95+
return {
96+
getCurrentConnectionInfo() {
97+
if (!connectionInfoRef.current) {
98+
if (process.env.NODE_ENV !== 'test') {
99+
throw new Error(
100+
'Could not find the current ConnectionInfo. Did you forget to setup the ConnectionInfoContext?'
101+
);
102+
}
103+
return TEST_CONNECTION_INFO;
98104
}
99-
return TEST_CONNECTION_INFO;
100-
}
101-
return connectionInfoRef.current;
102-
},
103-
};
105+
return connectionInfoRef.current;
106+
},
107+
};
108+
});
109+
return access;
104110
};
105111
export const connectionInfoAccessLocator = createServiceLocator(
106112
useConnectionInfoAccess,

0 commit comments

Comments
 (0)