Skip to content

Instantly share code, notes, and snippets.

@loveyunk
Created February 7, 2019 09:01
Show Gist options
  • Save loveyunk/887684bfcc5bffe44fac2da56c0aa71c to your computer and use it in GitHub Desktop.
Save loveyunk/887684bfcc5bffe44fac2da56c0aa71c to your computer and use it in GitHub Desktop.
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