11// @flow
2- const React = require ( "react" ) ;
3- const { DOM : dom , PropTypes } = React ;
2+ import { DOM as dom , PropTypes , createClass , createElement } from "react" ;
3+ import Svg from "./Svg" ;
44
5- const { div } = dom ;
6- const Svg = require ( "./Svg" ) ;
7-
8- require ( "./Accordion.css" ) ;
5+ import "./Accordion.css" ;
96
107type AccordionItem = {
118 buttons ?: Array < Object > ,
@@ -18,7 +15,7 @@ type AccordionItem = {
1815
1916type Props = { items : Array < Object > } ;
2017
21- const Accordion = React . createClass ( {
18+ const Accordion = createClass ( {
2219 propTypes : { items : PropTypes . array . isRequired } ,
2320 displayName : "Accordion" ,
2421 getInitialState ( ) {
@@ -57,9 +54,9 @@ const Accordion = React.createClass({
5754 . toLowerCase ( )
5855 . replace ( / \s / g, "-" ) } -pane`;
5956
60- return div (
57+ return dom . div (
6158 { className : containerClassName , key : i } ,
62- div (
59+ dom . div (
6360 { className : "_header" , onClick : ( ) => this . handleHeaderClick ( i ) } ,
6461 Svg ( "arrow" , { className : opened [ i ] ? "expanded" : "" } ) ,
6562 item . header ,
@@ -68,22 +65,22 @@ const Accordion = React.createClass({
6865 : null
6966 ) ,
7067 created [ i ] || opened [ i ]
71- ? div (
68+ ? dom . div (
7269 {
7370 className : "_content" ,
7471 style : { display : opened [ i ] ? "block" : "none" } ,
7572 } ,
76- React . createElement ( item . component , item . componentProps || { } )
73+ createElement ( item . component , item . componentProps || { } )
7774 )
7875 : null
7976 ) ;
8077 } ,
8178 render ( ) {
82- return div (
79+ return dom . div (
8380 { className : "accordion" } ,
8481 this . props . items . map ( this . renderContainer )
8582 ) ;
8683 } ,
8784} ) ;
8885
89- module . exports = Accordion ;
86+ export default Accordion ;
0 commit comments