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

feat: onClick is no longer required on navbar and steplink #441

Merged
merged 1 commit into from
Jul 22, 2020

Conversation

johnmeunier
Copy link
Contributor

Related issue

Description of the issue

onClick prop was required on some component. If you know other useless required prop, add them on this PR.

Person(s) for reviewing proposed changes

$ npm test

# watch for changes
$ npm test -- --watch

# For a specific file (e.g., in packages/context/__tests__/command.test.js)
$ npm test -- --watch packages/action

@@ -8,7 +8,7 @@ const propTypes = {
...Constants.propTypes,
id: PropTypes.string.isRequired,
href: PropTypes.string,
onClick: PropTypes.func.isRequired,
onClick: PropTypes.func,
Copy link
Contributor

Choose a reason for hiding this comment

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

May be you should check if(onClick != null)

onClick(e) {
e.preventDefault();
const { id, href, number, title, onClick } = this.props;
onClick({
href,
number,
id,
title,
});
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Where do you find this code code ?

Copy link
Contributor

Choose a reason for hiding this comment

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

onto this file => packages/Form/steps/src/StepLink.js
the idea is to secure the remove of is required for all the use case.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure that correspond to my problem. Indeed, each time I use a Step component without an onClick props, I have an error in the console. If I add a onClick condition without removing the isRequired from the PropTypes declaration, the error will still be in the console.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@samuel-gomez-axa , what do you think about this ?

Copy link
Contributor

Choose a reason for hiding this comment

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

No problem, you can set this props optional to remove the warning.

But if you just set this props not required, the StepLink will try to call the onClick and throw an error like this :
image

So you have to verify if this onClick props is not null and not call if its null

Copy link
Contributor

Choose a reason for hiding this comment

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

can you add an example in the story , please ?
with no onClick props : https://github.com/AxaGuilDEv/react-toolkit/tree/master/storybook/storybook/src/packages/Form/steps/src

@@ -7,7 +7,7 @@ import { setPosition } from './NavBar.helpers';
const propTypes = {
...Constants.propTypes,
isVisible: PropTypes.bool.isRequired,
onClick: PropTypes.func.isRequired,
onClick: PropTypes.func,
Copy link
Contributor

Choose a reason for hiding this comment

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

no problem here for just set props not required :)

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

@xballoy xballoy left a comment

Choose a reason for hiding this comment

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

LGTM

@mergify mergify bot merged commit 723d48e into master Jul 22, 2020
@delete-merged-branch delete-merged-branch bot deleted the feature/onclick branch July 22, 2020 08:37
guillaume-chervet pushed a commit that referenced this pull request Sep 1, 2020
Co-authored-by: Johnathan MEUNIER <jonathan.meunier@axa.fr>
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.

None yet

5 participants