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

Frontend/#043 button and link components #56

Closed

Conversation

vieraboschkova
Copy link
Collaborator

closes #43

@vieraboschkova vieraboschkova self-assigned this Feb 28, 2021
@vieraboschkova vieraboschkova marked this pull request as ready for review February 28, 2021 20:20
Copy link
Collaborator

@aleksanderwalczuk aleksanderwalczuk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my opinion it's the seed to spaghetti code. I find this code way more difficult in usage and it doesn't bring anything more than standard <button> element.

Comment on lines +3 to 9
function Button({ textToDisplay, classes, callback }) {
return (
<button className={classes} onClick={callback}>
{textToDisplay}
</button>
);
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't you think it's way more complicated to use buttons like this?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you suggest any specific solution to this problem?

Copy link
Collaborator

@aleksanderwalczuk aleksanderwalczuk Mar 1, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@synowa just use buttons as standard jsx element. There's no need to extract it to a separate component right now.
Let's say:

<codeBefore/>
<button anyPropsINeedRightNow>anyText</button>
<codeAfter/>

Pros:

  1. No imports (less messy components directory in the future)
  2. Every additional prop that's not defined in Button component would have to be declared

If your not able to define how many props you'll need then you should use the spread operator

const Example = (props) => (
    <someElement ...props>{props.children}</someElement>
);

props.children stands for any child you put inside this component, eg. text or another component

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually had in mind a very specific button, with specific style and function - a go back button, using props.history.goBack(). But I didn't have time to implement it yet. So far yes, it is reduntant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

FRONTEND | Button Component
3 participants