Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor: Optimize Button component and remove commented-out code #38

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 11 additions & 31 deletions src/components/Button.js
Original file line number Diff line number Diff line change
@@ -1,38 +1,16 @@
// import React from 'react';
// import './Button.css';
// import { Link } from 'react-router-dom';
import React from "react";
import "./Button.css";
import { Link } from "react-router-dom";

// export function Button() {
// return (
// <Link to='sign-up'>
// <button className='btn'>Sign Up</button>
// </Link>
// );
// }

import React from 'react';
import './Button.css';
import { Link } from 'react-router-dom';

const STYLES = ['btn--primary', 'btn--outline', 'btn--test'];

const SIZES = ['btn--medium', 'btn--large'];

export const Button = ({
children,
type,
onClick,
buttonStyle,
buttonSize
}) => {
const checkButtonStyle = STYLES.includes(buttonStyle)
? buttonStyle
: STYLES[0];
const STYLES = ["btn--primary", "btn--outline", "btn--test"];
const SIZES = ["btn--medium", "btn--large"];

const Button = React.memo(({ children, type, onClick, buttonStyle, buttonSize }) => {
const checkButtonStyle = STYLES.includes(buttonStyle) ? buttonStyle : STYLES[0];
const checkButtonSize = SIZES.includes(buttonSize) ? buttonSize : SIZES[0];

return (
<Link to='/sign-up' className='btn-mobile'>
<Link to="/sign-up" className="btn-mobile">
<button
className={`btn ${checkButtonStyle} ${checkButtonSize}`}
onClick={onClick}
Expand All @@ -42,4 +20,6 @@ export const Button = ({
</button>
</Link>
);
};
});

export default Button;