@@ -50,18 +50,16 @@ export function FormInstance(config) {
50
50
this . onChange = this . onChange . bind ( this ) ;
51
51
52
52
this . render = function ( ) {
53
+ if ( ReactDOM . hasOwnProperty ( 'createRoot' ) )
54
+ this . _renderReact18 ( ) ;
55
+ else
56
+ this . _renderReact17 ( ) ;
57
+ } ;
58
+
59
+ this . _renderReact17 = function ( ) {
53
60
try {
54
61
ReactDOM . render (
55
- < FormContainer
56
- schema = { this . schema }
57
- dataInputId = { this . dataInputId }
58
- data = { this . data }
59
- errorMap = { this . errorMap }
60
- fileHandler = { this . fileHandler }
61
- fileHandlerArgs = { this . fileHandlerArgs }
62
- onChange = { this . onChange }
63
- readonly = { this . readonly }
64
- /> ,
62
+ this . _getFormContainerComponent ( ) ,
65
63
document . getElementById ( this . containerId )
66
64
) ;
67
65
} catch ( error ) {
@@ -72,6 +70,31 @@ export function FormInstance(config) {
72
70
}
73
71
} ;
74
72
73
+ this . _renderReact18 = function ( ) {
74
+ const root = ReactDOM . createRoot ( document . getElementById ( this . containerId ) ) ;
75
+
76
+ try {
77
+ root . render ( this . _getFormContainerComponent ( ) ) ;
78
+ } catch ( error ) {
79
+ root . render ( < ErrorReporter error = { error } /> ) ;
80
+ }
81
+ } ;
82
+
83
+ this . _getFormContainerComponent = function ( ) {
84
+ return (
85
+ < FormContainer
86
+ schema = { this . schema }
87
+ dataInputId = { this . dataInputId }
88
+ data = { this . data }
89
+ errorMap = { this . errorMap }
90
+ fileHandler = { this . fileHandler }
91
+ fileHandlerArgs = { this . fileHandlerArgs }
92
+ onChange = { this . onChange }
93
+ readonly = { this . readonly }
94
+ />
95
+ ) ;
96
+ } ;
97
+
75
98
this . update = function ( config ) {
76
99
this . schema = config . schema || this . schema ;
77
100
this . data = config . data || this . data ;
0 commit comments