MCPcopy Index your code
hub / github.com/reactstrap/reactstrap / Button

Function Button

src/Button.js:40–102  ·  view source on GitHub ↗
(props)

Source from the content-addressed store, hash-verified

38};
39
40function Button(props) {
41 const onClick = useCallback(
42 (e) => {
43 if (props.disabled) {
44 e.preventDefault();
45 return;
46 }
47
48 if (props.onClick) {
49 return props.onClick(e);
50 }
51 },
52 [props.onClick, props.disabled],
53 );
54
55 let {
56 active,
57 'aria-label': ariaLabel,
58 block,
59 className,
60 close,
61 cssModule,
62 color = 'secondary',
63 outline,
64 size,
65 tag: Tag = 'button',
66 innerRef,
67 ...attributes
68 } = props;
69
70 if (close) {
71 return <CloseButton {...attributes} />;
72 }
73
74 const btnOutlineColor = `btn${outline ? '-outline' : ''}-${color}`;
75
76 const classes = mapToCssModules(
77 classNames(
78 className,
79 'btn',
80 btnOutlineColor,
81 size ? `btn-${size}` : false,
82 block ? 'd-block w-100' : false,
83 { active, disabled: props.disabled },
84 ),
85 cssModule,
86 );
87
88 if (attributes.href && Tag === 'button') {
89 Tag = 'a';
90 }
91
92 return (
93 <Tag
94 type={Tag === 'button' && attributes.onClick ? 'button' : undefined}
95 {...attributes}
96 className={classes}
97 ref={innerRef}

Callers

nothing calls this directly

Calls 2

mapToCssModulesFunction · 0.90
onClickMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…