I was trying to create a Dynamic Form component with a condition in the <items> tag and I got an error...
I allowed myself to find the place where the error appears in debugging mode and found it.
After a small change, the error disappeared and everything works.
Could you accept my changes?
ReactComponent.js
Code:
render() { var newUser = true; var newPassword = false; return ( <> <DynamicForm ID="userDataForm" numCols="2" autoFocus="true" margin={CONSTANT.PADDING} cellPadding={CONSTANT.PADDING} width="99%" titleWidth="150" titleAlign="left" minHintWidth="3"> <items> <TextItem name={CONSTANT._NAME} defaultValue={user[CONSTANT._NAME]} disabled={newUser ? "false" : "true"} hint={newUser ? "*" : ""} selectOnFocus="true" width="*"> {newUser && <icons> <FormItemIcon src={CONSTANT.BUTTONS_ICONS + "check_srv.png"} inline="false" tabIndex="-1" showOver="true" click={this.isUserNameFree} /> </icons> } </TextItem> {newPassword && <PasswordItem name={CONSTANT.PASSWORD} hint={newUser ? "*" : ""} selectOnFocus="true" width="*"> {newUser && <icons> <FormItemIcon src={CONSTANT.BUTTONS_ICONS + "info.png"} inline="false" tabIndex="-1" showOver="true" click={this.showPasswordInfo} /> </icons> } </PasswordItem> } {(newUser && newPassword) && <PasswordItem name="verifypassword" hint={newUser ? "*" : ""} selectOnFocus="true" width="*"> </PasswordItem> } </items> </DynamicForm> </> );
Code:
Syntax error parsing the JSX for property '' at http://localhost:3000/static/js/bundle.js:42370:15 at Array.forEach (<anonymous>) at DynamicForm.getPropertyValue (http://localhost:3000/static/js/bundle.js:42323:25) at DynamicForm._getComponentConfigWithChildren (http://localhost:3000/static/js/bundle.js:42257:32) at DynamicForm.getComponentConfigWithChildren (http://localhost:3000/static/js/bundle.js:42220:17) at DynamicForm._createSCInstance (http://localhost:3000/static/js/bundle.js:42091:23) at DynamicForm.componentDidMount (http://localhost:3000/static/js/bundle.js:42034:10) at commitLayoutEffectOnFiber (http://localhost:3000/static/js/bundle.js:69962:34) at commitLayoutMountEffects_complete (http://localhost:3000/static/js/bundle.js:71129:13) at commitLayoutEffects_begin (http://localhost:3000/static/js/bundle.js:71118:11) at commitLayoutEffects (http://localhost:3000/static/js/bundle.js:71064:7) at commitRootImpl (http://localhost:3000/static/js/bundle.js:72973:9) at commitRoot (http://localhost:3000/static/js/bundle.js:72853:9) at finishConcurrentRender (http://localhost:3000/static/js/bundle.js:72250:13) at performConcurrentWorkOnRoot (http://localhost:3000/static/js/bundle.js:72101:11) at workLoop (http://localhost:3000/static/js/bundle.js:80050:38) at flushWork (http://localhost:3000/static/js/bundle.js:80028:18) at MessagePort.performWorkUntilDeadline (http://localhost:3000/static/js/bundle.js:80265:25)
After a small change, the error disappeared and everything works.
Could you accept my changes?
ReactComponent.js
Code:
... getPropertyValue(propName, propObj, typeDescriptor, locator, inline) { .... localProps.children.forEach( (item, index) => { // ------------------ add for me -------------- if(!item) { return; } //-------------------------------------------
Comment