You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
712 B
32 lines
712 B
class FancyButton extends React.Component {
|
|
buttonRef = React.createRef();
|
|
|
|
focus() {
|
|
this.buttonRef.current.focus();
|
|
}
|
|
|
|
render() {
|
|
// highlight-next-line
|
|
const {label, theme, ...rest} = this.props;
|
|
// highlight-range{5}
|
|
return (
|
|
<button
|
|
{...rest}
|
|
className={`${theme}-button`}
|
|
ref={this.buttonRef}>
|
|
{label}
|
|
</button>
|
|
);
|
|
}
|
|
}
|
|
|
|
// highlight-next-line
|
|
const FancyThemedButton = withTheme(FancyButton);
|
|
|
|
// We can render FancyThemedButton as if it were a FancyButton
|
|
// It will automatically receive the current "theme",
|
|
// And the HOC will pass through our other props.
|
|
<FancyThemedButton
|
|
label="Click me!"
|
|
onClick={handleClick}
|
|
/>;
|
|
|