Skip to content

Commit 463b302

Browse files
authored
Merge pull request #37 from membean/fix/default-props-warning
Removed default props as it is no more supported
2 parents dd53b95 + d022c3c commit 463b302

File tree

3 files changed

+18
-32
lines changed

3 files changed

+18
-32
lines changed

src/lib/components/DefinitionTooltip/DefinitionTooltip.js

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,24 +30,24 @@ import positionTooltip from "../../helpers/positionTooltip.js";
3030
url [String] - A url to link to. Will take precedence over onClick.
3131
*/
3232

33-
const DefinitionTooltip = props => {
33+
const DefinitionTooltip = (props) => {
3434
const {
3535
classes,
3636
definition,
3737
explanation,
3838
id,
3939
link,
4040
onClick,
41-
position,
41+
position = "top",
4242
term,
43-
url
43+
url,
4444
} = props;
4545

4646
const tooltipElementId = `${id}-desc`;
4747
const tooltipRef = useRef(null);
4848
const triggerClass = classnames("dfn-tooltip-trigger", classes);
4949

50-
const handleMouseEnter = event => {
50+
const handleMouseEnter = (event) => {
5151
const currentTooltip = tooltipRef.current;
5252
positionTooltip(currentTooltip, position);
5353
};
@@ -68,7 +68,7 @@ const DefinitionTooltip = props => {
6868
aria-labelledby={tooltipElementId}
6969
className={triggerClass}
7070
dangerouslySetInnerHTML={{
71-
__html: term
71+
__html: term,
7272
}}
7373
href={url}
7474
onMouseEnter={handleMouseEnter}
@@ -82,7 +82,7 @@ const DefinitionTooltip = props => {
8282
aria-labelledby={tooltipElementId}
8383
className={triggerClass}
8484
dangerouslySetInnerHTML={{
85-
__html: term
85+
__html: term,
8686
}}
8787
onClick={onClick}
8888
onMouseEnter={handleMouseEnter}
@@ -100,7 +100,7 @@ const DefinitionTooltip = props => {
100100
>
101101
<span
102102
dangerouslySetInnerHTML={{
103-
__html: term
103+
__html: term,
104104
}}
105105
/>
106106
</Link>
@@ -118,7 +118,7 @@ const DefinitionTooltip = props => {
118118
>
119119
<p
120120
dangerouslySetInnerHTML={{
121-
__html: `<dfn>${term}:</dfn> ${definition}`
121+
__html: `<dfn>${term}:</dfn> ${definition}`,
122122
}}
123123
id={`${id}-definition`}
124124
/>
@@ -134,10 +134,6 @@ const DefinitionTooltip = props => {
134134
);
135135
};
136136

137-
DefinitionTooltip.defaultProps = {
138-
position: "top"
139-
};
140-
141137
DefinitionTooltip.propTypes = {
142138
classes: PropTypes.string,
143139
definition: PropTypes.string.isRequired,
@@ -147,7 +143,7 @@ DefinitionTooltip.propTypes = {
147143
onClick: PropTypes.func,
148144
position: PropTypes.oneOf(["bottom", "left", "right", "top"]),
149145
term: PropTypes.string.isRequired,
150-
url: PropTypes.string
146+
url: PropTypes.string,
151147
};
152148

153149
export default DefinitionTooltip;

src/lib/components/TextInput/TextInput.js

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ import classnames from "classnames";
5959
const TextInput = React.forwardRef((props, ref) => {
6060
const {
6161
autoComplete,
62-
autoFocus,
62+
autoFocus = false,
6363
classes,
6464
disabled,
6565
feedbackContext,
@@ -79,22 +79,22 @@ const TextInput = React.forwardRef((props, ref) => {
7979
placeholder,
8080
polite,
8181
readOnly,
82-
required,
82+
required = false,
8383
step,
8484
type,
85-
value
85+
value,
8686
} = props;
8787

8888
const controlClasses = classnames("text", "control", classes, {
8989
disabled: disabled,
9090
inline: inline,
91-
invalid: isValid !== undefined && !isValid
91+
invalid: isValid !== undefined && !isValid,
9292
});
9393
const feedbackClasses = classnames(
9494
"control-feedback",
9595
`${feedbackContext || "error"}`,
9696
{
97-
"visually-hidden": !feedbackText
97+
"visually-hidden": !feedbackText,
9898
}
9999
);
100100
const feedbackId = `${id}-feedback`;
@@ -191,14 +191,9 @@ TextInput.propTypes = {
191191
"text",
192192
"time",
193193
"url",
194-
"week"
194+
"week",
195195
]),
196-
value: PropTypes.string
197-
};
198-
199-
TextInput.defaultProps = {
200-
autoFocus: false,
201-
required: false
196+
value: PropTypes.string,
202197
};
203198

204199
export default TextInput;

src/lib/components/Tooltip/Tooltip.js

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@ const Tooltip = (props) => {
3838
id,
3939
link,
4040
onClick,
41-
position,
41+
position = "top",
4242
text,
4343
tooltipBody,
4444
url,
45-
buttonType
45+
buttonType = "button",
4646
} = props;
4747

4848
const tooltipElementId = `${id}-desc`;
@@ -119,11 +119,6 @@ const Tooltip = (props) => {
119119
);
120120
};
121121

122-
Tooltip.defaultProps = {
123-
position: "top",
124-
buttonType: "button"
125-
};
126-
127122
Tooltip.propTypes = {
128123
classes: PropTypes.string,
129124
tooltipBody: PropTypes.string.isRequired,

0 commit comments

Comments
 (0)