|
@@ -73,7 +73,6 @@ interface IProps {
|
|
|
}
|
|
|
|
|
|
interface IState {
|
|
|
- roleId: string;
|
|
|
visible: boolean;
|
|
|
bannerList: IBanner[];
|
|
|
loading: boolean;
|
|
@@ -86,14 +85,15 @@ const MemoSwiperModal = memo(SwiperModal);
|
|
|
|
|
|
const Banner: React.FC<IProps> = ({ roleList, dispatch }) => {
|
|
|
const [state, setState] = useState<IState>({
|
|
|
- roleId: '',
|
|
|
visible: false,
|
|
|
modalVisible: false,
|
|
|
loading: false,
|
|
|
bannerList: [],
|
|
|
});
|
|
|
|
|
|
- const { roleId, visible, bannerList, loading, modalVisible } = state;
|
|
|
+ const [roleId, setRoleId] = useState<string>('');
|
|
|
+
|
|
|
+ const { visible, bannerList, loading, modalVisible } = state;
|
|
|
|
|
|
// 请求身份分类
|
|
|
useEffect(() => {
|
|
@@ -110,10 +110,7 @@ const Banner: React.FC<IProps> = ({ roleList, dispatch }) => {
|
|
|
useEffect(() => {
|
|
|
if (roleList.length === 0) return;
|
|
|
|
|
|
- setState({
|
|
|
- ...state,
|
|
|
- roleId: roleList[0].id,
|
|
|
- });
|
|
|
+ setRoleId(roleList[0].id);
|
|
|
}, [roleList]);
|
|
|
|
|
|
useEffect(() => {
|
|
@@ -286,9 +283,7 @@ const Banner: React.FC<IProps> = ({ roleList, dispatch }) => {
|
|
|
tab: role.label,
|
|
|
};
|
|
|
})}
|
|
|
- onTabChange={(activeKey) => {
|
|
|
- setState({ ...state, roleId: activeKey });
|
|
|
- }}
|
|
|
+ onTabChange={(activeKey) => setRoleId(activeKey)}
|
|
|
>
|
|
|
<Card
|
|
|
extra={
|