I am looking to make some changes to code form a project that I have taken on. I had to disable the webpack plugin from setting the baseURL, and now when the page loads in index.jsx to get the constructor to call the getResources and make getResources explicitly set the process.env.baseURL. I have added the getResources to main.jsx but not being sure about the constructor in index.jsx. If anyone has any expertise on this and can help that would be great. I will provide code below:
main.jsx
let baseURL = process.env.baseURL;
export function getResources() {
if (process.env.APP_SERVER_URL) {
baseURL = process.env.APP_SERVER_URL;
} else {
let urlPath = getHref() + '/api/v1/resources';
return request.get(urlPath).then(function (response) {
baseURL = response.data;
});
}
}
export default class IndexDisplay extends React.Component {
constructor() {
super();
this.state = { branchData: "",
displayComponent:"root",
templateData: []
}
}
componentWillMount() {
axios.get(baseURL + 'workflow')
.then(function (response) {
this.setState({
"templateData": ParseWorkflows(response.data)
},this.updateState)
}.bind(this));
}
..............
index.jsx
import React from 'react'
import ReactDOM from 'react-dom'
import {Router, Route, browserHistory, IndexRoute} from "react-router"
import WorkflowTemplateListDisplay
from'./template_list_view/workflowTemplateListDisplay.jsx'
import WorkflowTemplateByAgencyDisplay from
'./template_list_view/workflowTemplateByAgencyDisplay.jsx'
import WorkflowInstanceDisplay from
'./workflowInstanceView/workflowInstanceDisplay.jsx'
import GraphicalViewDisplay from
'./workflowGraphicalView/graphicalViewDisplay.jsx'
import WorkflowStepsTemplateDisplay
from'./templateStepsView/workflowStepsTemplateDisplay.jsx';
import WorkflowSearchByWorkflowIdDisplay from
'./searchByWorkflowID/workflowSearchByWorkflowIdDisplay.jsx'
import WorkflowTemplateMultiSearchDisplay from
'./template_list_view/workflowTemplateMultiSearchDisplay.jsx'
import TemplatesHierarchyTableDisplay from
'./template_list_view/components/TemplatesHierarchyTable.jsx'
import Main from './main.jsx'
ReactDOM.render((
<Router history={browserHistory}>
<Route path='/' component={Main}>
<IndexRoute component={WorkflowTemplateListDisplay}/>
<Route path='/workflowInstances' component={WorkflowInstanceDisplay}/>
<Route path='/workflowStepsTemplate' component={WorkflowStepsTemplateDisplay}/>
<Route path='/pictorialView' component={GraphicalViewDisplay}/>
<Route path='/workflowTemplateByAgency' component={WorkflowTemplateByAgencyDisplay}/>
<Route path='/searchByWorkflowID' component={WorkflowSearchByWorkflowIdDisplay}/>
<Route path='/search' component={WorkflowTemplateMultiSearchDisplay}/>
<Route path='/treeView' component={TemplatesHierarchyTableDisplay}/>
</Route>
</Router>), document.getElementById('app'));