Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[docs] Fix popover anchor playground crash #20265

Merged
merged 2 commits into from
Mar 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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