我正在尝试实现子菜单(嵌套菜单)。
值得一提的是,我使用的是hydra组件,以前没有关于redux的经验(由于这个特定问题,几天前就开始学习它)。
我遵循了material-ui上提供的嵌套列表https://material-ui.com/demos/lists/#nested-list的示例。以及来自https://marmelab.com/react-admin/Theming.html#using-a-custom-menu的教程, 以实现自定义菜单。
所以我有几个问题。
1)我可以有状态组件(MyMenu)来处理菜单项的切换吗?
一个例子与react-admin无关,只是我的意思。
import React, { Component } from "react";
import { connect } from "react-redux";
import { addArticle } from "../actions/index";
const mapDispatchToProps = dispatch => {
return {
addArticle: article => dispatch(addArticle(article))
};
};
class ConnectedForm extends Component {
constructor() {
super();
this.state = {
title: ""
};
this.handleChange = this.handleChange.bind(this);
this.handleSubmit = this.handleSubmit.bind(this);
}
handleChange(event) {
this.setState({ [event.target.id]: event.target.value });
}
handleSubmit(event) {
event.preventDefault();
const { title } = …Run Code Online (Sandbox Code Playgroud)