I built a react-app that is implemented on 3rd party sites as widget. The widget uses a REST API and renders different content in a react-modal depending on the app's state. For building the app I use webpack. Now the following problem appears:
**On one specific site the modal still opens on click, but no content is rendered (although there are quite many child components with proper values). **
- this issue appears only on one specific site. The site is a magento page with a lot of other stuff going on
- if I copy the HTML markup of the site in question and place it on my own server, my react app works as intended. This is why I rule out any conflict between js libraries because they would appear here, too.
- on any other site my react app works as intended
- there are no console errors or warnings in chrome dev tools
- all tests have been run with cleared storage to make sure nothing is working/not working because of cached files
Here are some bits of code which I hope are relevant but I am not sure the problem actually lies in this part. Within render()
based on the state different components are defined:
let component;
switch (this.state.currentView) {
case 'questionnaire':
component = <QuestionnaireView
{...commonComponentProps}
intro={this.state.intro}
questions={this.state.questions}
advance={this.advanceView}
updateQuestions={this.updateQuestions}
/>;
break;
case 'closure':
component = <ClosureView
{...commonComponentProps}
closure={this.state.closure}
submit={this.submitAnswers}
goBack={this.goBackView}
/>;
break;
case 'results':
component = <ResultsView
{...commonComponentProps}
results={this.state.results}
reset={this.resetApp}
userToken={this.state.userToken}
/>;
break;
default:
return false;
}
Then in the modal the value is rendered
<Modal
className="questionnaire-component"
isOpen={this.state.modalIsOpen}
onRequestClose={() => this.setState({modalIsOpen: false})}
style={ModalStyles}
contentLabel="Questionnaire"
onClick={this.closeModal}
>
{this.state.loading ?
<div style={{display: 'flex',justifyContent: 'center',margin: '50px'}}>
<Loading type='balls' color='#3C3C3B'/>
</div>
:
component
}
</Modal>
By inspecting the values I can say that component
actually contains the correct values. Also if I make a test and render <Modal><p>Hello World!</p></Modal>
this also does not render BUT as said in the beginning this applies only to one specific host site, it usually works everywhere.