@codecademy/brand 2.4.0 → 2.4.1-alpha.78560defd9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -16,7 +16,7 @@ export function RecurlyProvider({
16
16
  }) {
17
17
  const [recurly, setRecurly] = useState(undefined);
18
18
  useEffect(() => {
19
- loadRecurly(config).then(setRecurly);
19
+ loadRecurly(config)?.then(setRecurly);
20
20
  // Exclude `config` dependency as it should be treated as static.
21
21
  // eslint-disable-next-line react-hooks/exhaustive-deps
22
22
  }, []);
@@ -3,4 +3,4 @@ export type RecurlyConfig = {
3
3
  publicKey: string;
4
4
  required: string[];
5
5
  };
6
- export declare function loadRecurly(config: RecurlyConfig): Promise<Recurly>;
6
+ export declare function loadRecurly(config: RecurlyConfig): Promise<Recurly> | undefined;
@@ -1,6 +1,6 @@
1
1
  import { w } from './w';
2
2
  export function loadRecurly(config) {
3
- if (!w._recurlyPromise) {
3
+ if (w && w._recurlyPromise) {
4
4
  w._recurlyPromise = new Promise(resolve => {
5
5
  const script = w.document.createElement('script');
6
6
  script.src = 'https://js.recurly.com/v4/recurly.js';
@@ -18,5 +18,5 @@ export function loadRecurly(config) {
18
18
  w.document.head.appendChild(script);
19
19
  });
20
20
  }
21
- return w._recurlyPromise;
21
+ return w?._recurlyPromise;
22
22
  }
@@ -10,5 +10,5 @@ export type W = {
10
10
  _recurlyPromise?: Promise<Recurly>;
11
11
  document: Doc;
12
12
  };
13
- export declare const w: W;
13
+ export declare const w: W | undefined;
14
14
  export {};
@@ -1,4 +1,4 @@
1
1
  // By importing/exporting w as a window object, we can easily mock it in tests.
2
2
 
3
3
  // Exported for easy mocking
4
- export const w = window;
4
+ export const w = typeof window === 'undefined' ? undefined : window;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@codecademy/brand",
3
3
  "description": "Brand component library for Codecademy",
4
- "version": "2.4.0",
4
+ "version": "2.4.1-alpha.78560defd9.0",
5
5
  "author": "Codecademy Engineering <dev@codecademy.com>",
6
6
  "dependencies": {
7
7
  "@emotion/is-prop-valid": "^1.2.1",