@@ -50,18 +50,16 @@ export function FormInstance(config) {
5050 this . onChange = this . onChange . bind ( this ) ;
5151
5252 this . render = function ( ) {
53+ if ( ReactDOM . hasOwnProperty ( 'createRoot' ) )
54+ this . _renderReact18 ( ) ;
55+ else
56+ this . _renderReact17 ( ) ;
57+ } ;
58+
59+ this . _renderReact17 = function ( ) {
5360 try {
5461 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 ( ) ,
6563 document . getElementById ( this . containerId )
6664 ) ;
6765 } catch ( error ) {
@@ -72,6 +70,31 @@ export function FormInstance(config) {
7270 }
7371 } ;
7472
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+
7598 this . update = function ( config ) {
7699 this . schema = config . schema || this . schema ;
77100 this . data = config . data || this . data ;
0 commit comments