@seamlessdocs/payment-modals 2.0.0-beta.4 → 2.0.0-beta.6
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.
- package/build/payment-modals.js +1 -1
- package/package.json +1 -1
- package/src/index.jsx +16 -25
package/package.json
CHANGED
package/src/index.jsx
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
// Import createRoot - webpack will handle this correctly:
|
|
2
|
-
// - In development: bundled from react-dom/client
|
|
3
|
-
// - In production: external, resolved to ReactDOM global via webpack externals
|
|
4
|
-
import { createRoot as createRootFromModule } from 'react-dom/client';
|
|
5
|
-
|
|
6
1
|
import ChooseModal from './Components/ChooseModal';
|
|
7
2
|
import ProcessingModal from './Components/ProcessingModal';
|
|
8
3
|
import ErrorModal from './Components/ErrorModal';
|
|
@@ -24,45 +19,41 @@ const rootInstances = new Map();
|
|
|
24
19
|
|
|
25
20
|
// Helper function to get createRoot - handles both bundled (dev) and external (prod) scenarios
|
|
26
21
|
const getCreateRoot = () => {
|
|
27
|
-
// Strategy 1:
|
|
28
|
-
|
|
29
|
-
|
|
22
|
+
// Strategy 1: Access ReactDOM from global scope FIRST (works in production with externals)
|
|
23
|
+
// This is the primary method for production builds where react-dom is external
|
|
24
|
+
const ReactDOM = (typeof window !== 'undefined' && window.ReactDOM)
|
|
25
|
+
|| (typeof global !== 'undefined' && global.ReactDOM)
|
|
26
|
+
|| (typeof self !== 'undefined' && self.ReactDOM);
|
|
27
|
+
|
|
28
|
+
if (ReactDOM && typeof ReactDOM.createRoot === 'function') {
|
|
29
|
+
return ReactDOM.createRoot;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
// Strategy 2: Try to require react-dom/client directly (works in development)
|
|
32
|
+
// Strategy 2: Try to require react-dom/client directly (works in development only)
|
|
33
|
+
// Only use this in development when react-dom is bundled
|
|
33
34
|
try {
|
|
34
35
|
const reactDomClient = require('react-dom/client');
|
|
35
36
|
if (reactDomClient && reactDomClient.createRoot && typeof reactDomClient.createRoot === 'function') {
|
|
36
37
|
return reactDomClient.createRoot;
|
|
37
38
|
}
|
|
38
39
|
} catch (e) {
|
|
39
|
-
// Ignore require errors - module might not be available
|
|
40
|
+
// Ignore require errors - module might not be available (especially in production)
|
|
40
41
|
}
|
|
41
42
|
|
|
42
|
-
// Strategy 3: Try to require react-dom and access createRoot (works in development)
|
|
43
|
+
// Strategy 3: Try to require react-dom and access createRoot (works in development only)
|
|
43
44
|
try {
|
|
44
|
-
const
|
|
45
|
-
if (
|
|
46
|
-
return
|
|
45
|
+
const ReactDOMModule = require('react-dom');
|
|
46
|
+
if (ReactDOMModule && typeof ReactDOMModule.createRoot === 'function') {
|
|
47
|
+
return ReactDOMModule.createRoot;
|
|
47
48
|
}
|
|
48
49
|
} catch (e) {
|
|
49
50
|
// Ignore require errors
|
|
50
51
|
}
|
|
51
52
|
|
|
52
|
-
// Strategy 4: Access ReactDOM from global scope (works in production with externals)
|
|
53
|
-
// Also works in development if React is loaded globally
|
|
54
|
-
const ReactDOM = (typeof window !== 'undefined' && window.ReactDOM)
|
|
55
|
-
|| (typeof global !== 'undefined' && global.ReactDOM)
|
|
56
|
-
|| (typeof self !== 'undefined' && self.ReactDOM);
|
|
57
|
-
|
|
58
|
-
if (ReactDOM && typeof ReactDOM.createRoot === 'function') {
|
|
59
|
-
return ReactDOM.createRoot;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
53
|
throw new Error(
|
|
63
54
|
'createRoot is not available. Make sure React 18 is loaded. ' +
|
|
64
55
|
'In development, react-dom should be bundled. ' +
|
|
65
|
-
'In production, ReactDOM should be available globally.'
|
|
56
|
+
'In production, ReactDOM should be available globally as window.ReactDOM.'
|
|
66
57
|
);
|
|
67
58
|
};
|
|
68
59
|
|