-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Button.js
34 lines (28 loc) · 843 Bytes
/
Button.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
'use strict';
const classNameProp = require('class-name-prop');
const PropTypes = require('prop-types');
const React = require('react');
const propTypeChildren = require('../utils/propTypeChildren');
const Button = React.forwardRef(({ disabled, className, ...props }, ref) => {
const [isMounted, setIsMounted] = React.useState(false);
React.useEffect(() => {
setIsMounted(true);
}, []);
return (
<button
className={classNameProp('daui-Button', className)}
disabled={disabled || !isMounted}
{...props}
ref={ref}
/>
);
});
if (typeof process === 'object' && process.env.NODE_ENV !== 'production') {
Button.displayName = 'Button';
Button.propTypes = {
disabled: PropTypes.bool,
className: PropTypes.string,
children: propTypeChildren.isRequired,
};
}
module.exports = Button;