diff --git a/components/menu/demo/switch-mode.md b/components/menu/demo/switch-mode.md index 9931d492d9..1601bb7930 100755 --- a/components/menu/demo/switch-mode.md +++ b/components/menu/demo/switch-mode.md @@ -25,69 +25,61 @@ import { const { SubMenu } = Menu; -class Sider extends React.Component { - state = { - mode: 'inline', - theme: 'light', +const Demo = () => { + const [mode, setMode] = React.useState('inline'); + const [theme, setTheme] = React.useState('light'); + + const changeMode = value => { + setMode(value ? 'vertical' : 'inline'); }; - changeMode = value => { - this.setState({ - mode: value ? 'vertical' : 'inline', - }); + const changeTheme = value => { + setTheme(value ? 'dark' : 'light'); }; - changeTheme = value => { - this.setState({ - theme: value ? 'dark' : 'light', - }); - }; - - render() { - return ( - <> - Change Mode - - Change Style -
-
- - }> - Navigation One - - }> - Navigation Two - - } title="Navigation Two"> - Option 3 - Option 4 - - Option 5 - Option 6 - + return ( + <> + Change Mode + + Change Style +
+
+ + }> + Navigation One + + }> + Navigation Two + + } title="Navigation Two"> + Option 3 + Option 4 + + Option 5 + Option 6 - } title="Navigation Three"> - Option 7 - Option 8 - Option 9 - Option 10 - - }> - - Ant Design - - - - - ); - } -} +
+ } title="Navigation Three"> + Option 7 + Option 8 + Option 9 + Option 10 + + }> + + Ant Design + + +
+ + ); +}; -ReactDOM.render(, mountNode); +ReactDOM.render(, mountNode); ```