Я хочу добавить динамический компонент в React, но он не работает.Я получаю правильное имя компонента, но похоже, что моя переменная в нем не работает:
componentDidMount() {
const currentLocation = this.props.location.pathname;
let route_name = 'Dashboard';
for (let i = 0; i < Route.length; i++) {
if (Route[i].path == currentLocation) {
route_name = Route[i].name;
break;
}
}
this.setState({
route_name: route_name
});
}
render() {
return (
<div className="admin-content">
<this.state.route_name />
</div>
);
}