Created
July 2, 2019 05:27
-
-
Save kenmori/b79fba9a9b002fc858c8d337b0b50650 to your computer and use it in GitHub Desktop.
React and
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
```js | |
import * as React from "react"; | |
import { | |
ExpansionPanel, | |
ExpansionPanelSummary, | |
ExpansionPanelDetails, | |
Typography, | |
} from "@material-ui/core"; | |
import { ExpandMore as ExpandMoreIcon } from "@material-ui/icons"; | |
import classes from "./classes.css"; | |
export interface StateProps { | |
description: string; | |
} | |
interface LocalState { | |
expanded: boolean; | |
} | |
type Props = StateProps; | |
const OwnAppDescriptionViewer:React.FC<Props> = ({description}) => { | |
const [state, setExpands] = React.useState<LocalState>({expanded: false}); | |
const handleChange = React.useCallback(() => { | |
setExpands((prevState) => ({ expanded: !prevState.expanded })); | |
},[setExpands]); | |
return ( | |
<> | |
<ExpansionPanel | |
expanded={state.expanded} | |
onChange={handleChange} | |
classes={{ | |
root: classes.ExpansionPanel, | |
expanded: classes.DescriptionBarExpanded, | |
}} | |
elevation={0} | |
square={true} | |
> | |
<ExpansionPanelSummary expandIcon={<ExpandMoreIcon />} /> | |
<ExpansionPanelDetails> | |
<Typography>{description}</Typography> | |
</ExpansionPanelDetails> | |
</ExpansionPanel> | |
</> | |
); | |
}; | |
export default OwnAppDescriptionViewer; | |
``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment