Skip to content

Commit

Permalink
[docs] Fix popover anchor playground crash (#20265)
Browse files Browse the repository at this point in the history
  • Loading branch information
Zaynex authored Mar 25, 2020
1 parent 32d647c commit f46c1e6
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 24 deletions.
7 changes: 4 additions & 3 deletions docs/src/pages/components/chips/ChipsPlayground.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,21 @@ const styles = (theme) => ({

function ChipsPlayground(props) {
const { classes } = props;
const [{ color, onDelete, avatar, icon, variant, size }, setState] = React.useState({
const [state, setState] = React.useState({
color: 'default',
onDelete: 'none',
avatar: 'none',
icon: 'none',
variant: 'default',
size: 'medium',
});
const { color, onDelete, avatar, icon, variant, size } = state;

const handleChange = (event) => {
setState((state) => ({
setState({
...state,
[event.target.name]: event.target.value,
}));
});
};

const handleDeleteExample = () => {
Expand Down
41 changes: 20 additions & 21 deletions docs/src/pages/components/popover/AnchorPlayground.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,19 +68,7 @@ function AnchorPlayground(props) {
const { classes } = props;
const anchorRef = React.useRef();

const [
{
open,
anchorOriginVertical,
anchorOriginHorizontal,
transformOriginVertical,
transformOriginHorizontal,
positionTop,
positionLeft,
anchorReference,
},
setState,
] = React.useState({
const [state, setState] = React.useState({
open: false,
anchorOriginVertical: 'top',
anchorOriginHorizontal: 'left',
Expand All @@ -91,32 +79,43 @@ function AnchorPlayground(props) {
anchorReference: 'anchorEl',
});

const {
open,
anchorOriginVertical,
anchorOriginHorizontal,
transformOriginVertical,
transformOriginHorizontal,
positionTop,
positionLeft,
anchorReference,
} = state;

const handleChange = (event) => {
setState((state) => ({
setState({
...state,
[event.target.name]: event.target.value,
}));
});
};

const handleNumberInputChange = (key) => (event) => {
setState((state) => ({
setState({
...state,
[key]: parseInt(event.target.value, 10),
}));
});
};

const handleClickButton = () => {
setState((state) => ({
setState({
...state,
open: true,
}));
});
};

const handleClose = () => {
setState((state) => ({
setState({
...state,
open: false,
}));
});
};

let mode = '';
Expand Down

0 comments on commit f46c1e6

Please sign in to comment.