Created
February 7, 2019 09:01
-
-
Save loveyunk/887684bfcc5bffe44fac2da56c0aa71c to your computer and use it in GitHub Desktop.
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
import React, { useState } from 'react'; | |
import className from 'classnames'; | |
import CSSModules from 'react-css-modules'; | |
import styles from './Foo.module.scss'; | |
export interface FooProps { | |
className?: string; | |
prefixCls?: string; | |
} | |
const defaultProps: FooProps = { | |
className: '', | |
prefixCls: 'lv-foo' | |
}; | |
const Foo: React.FC<FooProps> = props => { | |
const [count, setCount] = useState(0); | |
const handleClick = () => { | |
setCount(count + 1); | |
}; | |
const classes = className(props.prefixCls, props.className, {}); | |
return ( | |
<div styleName={classes}> | |
<p>count: {count}</p> | |
<button onClick={handleClick}>Add</button> | |
</div> | |
); | |
}; | |
Foo.defaultProps = defaultProps; | |
export default CSSModules(Foo, styles, { | |
allowMultiple: true | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment