Skip to content

Commit

Permalink
Revert "chore: export Button as function, not as const"
Browse files Browse the repository at this point in the history
This reverts commit 2dbd217.
  • Loading branch information
gpbl committed Dec 4, 2021
1 parent 1444daa commit 9a9b215
Showing 1 changed file with 24 additions and 24 deletions.
48 changes: 24 additions & 24 deletions packages/react-day-picker/src/components/Button/Button.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { LegacyRef } from 'react';
import React from 'react';

import { useDayPicker } from '../../contexts/DayPicker';

Expand All @@ -8,29 +8,29 @@ export type ButtonProps = React.HTMLProps<HTMLButtonElement>;
/**
* Render a button HTML element applying the reset class name.
*/
export function Button(
props: ButtonProps & { ref?: LegacyRef<HTMLButtonElement> }
): JSX.Element {
const { classNames, styles } = useDayPicker();
export const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
(props, ref) => {
const { classNames, styles } = useDayPicker();

const classNamesArr = [classNames.button_reset, classNames.button];
if (props.className) {
classNamesArr.push(props.className);
}
const className = classNamesArr.join(' ');
const classNamesArr = [classNames.button_reset, classNames.button];
if (props.className) {
classNamesArr.push(props.className);
}
const className = classNamesArr.join(' ');

const style = { ...styles.button_reset, ...styles.button };
if (props.style) {
Object.assign(style, props.style);
}
const style = { ...styles.button_reset, ...styles.button };
if (props.style) {
Object.assign(style, props.style);
}

return (
<button
{...props}
ref={props.ref}
type="button"
className={className}
style={style}
/>
);
}
return (
<button
{...props}
ref={ref}
type="button"
className={className}
style={style}
/>
);
}
);

0 comments on commit 9a9b215

Please sign in to comment.