在我的代码中,我没有在setState
方法中使用render
,但是仍然收到以下错误,如何找出错误的出处?
import React from "react";
import { connect } from "react-redux";
// import "./JeldwenViewer.css";
import Viewer from "../Viewer/Viewer";
import AppearanceOptions from "../AppearanceOptions";
import ViewportControl from "../ViewportControl";
class JeldwenViewer extends React.Component {
constructor(props) {
super(props);
this.state = {};
}
render() {
return (
<div>
{this.props.modelError.error ? (
<div className="container">
<div className="alert alert-danger" role="alert">
{this.props.modelError.message}
</div>
</div>
) : null}
<section id="content" className="ie-content">
<Viewer />
<ViewportControl />
<AppearanceOptions />
</section>
</div>
);
}
}
const mapStateToProps = state => {
return {
viewerData: state.viewerReducer.viewerData,
modelError: state.errorReducer.modelError
};
};
export default connect(mapStateToProps)(JeldwenViewer);
import React from "react";
import { connect } from "react-redux";
import JeldwenViewer from "./JeldwenViewer";
import { actions } from "../actions";
import { library } from "@fortawesome/fontawesome-svg-core";
import {
faMinusCircle,
faPlusCircle,
faChevronDown
} from "@fortawesome/free-solid-svg-icons";
library.add(faPlusCircle, faMinusCircle, faChevronDown);
class JeldwenViewerContainer extends React.Component {
constructor(props) {
super(props);
this.state = {
};
}
componentDidMount() {
if(this.props.product_data && this.props.product_data.token){
this.props.updateToken(this.props.product_data.token);
this.props.loadModel(this.props.product_data);
}
}
render() {
return (
<div id="jeldwenViewerContainer">
<div className="main">
<JeldwenViewer />
</div>
</div>
);
}
}
const mapStateToProps = state => {
return {
appState: state.viewerReducer.viewerData,
product_data: state.viztool.product_data
};
};
const mapDispatchToProps = dispatch => {
return {
updateToken: token => dispatch(actions.updateToken(token)),
loadModel: model => dispatch(actions.loadModel(model))
};
};
export default connect(
mapStateToProps,
mapDispatchToProps
)(JeldwenViewerContainer);