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

GH-1967 Themes Panel Update #510

Merged
merged 7 commits into from Apr 14, 2020

Remove console error

  • Loading branch information
benstrumeyer committed Mar 12, 2020
commit f9b154628d18d30ee46099f397b0340b30a0cf74
@@ -50,12 +50,12 @@ class RadioButtonGroup extends React.Component {
const { buttons } = this.state;
return (
this.props.items.map((item, index) => (
<div className="flex-container align-justify RadioButtonGroup__container">
<div className="flex-container align-justify RadioButtonGroup__container" key={`${index * 2}`}>
<span className="RadioButtonGroup__label">
{t(item.text)}
</span>
<div>
<RadioButton key={buttons[index]} checked={buttons[index]} handleClick={() => this.handleClick(index)} />
<RadioButton checked={buttons[index]} handleClick={() => this.handleClick(index)} />
This conversation was marked as resolved by Eden12345

This comment has been minimized.

@Eden12345

Eden12345 Mar 23, 2020
Contributor

It looks like this is the only place that you're using the local state in this component. You can instead just pass the props to the <RadioButton /> component like this:

const { indexClicked, handleItemClick } = this.props
// ...code in between...
	<RadioButton
		checked={index === indexClicked}
		handleClick={() => handleItemClick(index)}
	/>

Then, you can remove all of the code from componentDidMount and RadioButtonGroup.handleClick and not have to worry about local state.

This comment has been minimized.

@benstrumeyer

benstrumeyer Mar 31, 2020
Author Contributor

Good catch. Just deleted a whole buncha code and even made a functional component

</div>
</div>
))
@@ -8,6 +8,7 @@
* https://www.ghostery.com/
*
* Copyright 2019 Ghostery, Inc. All rights reserved.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0
ProTip! Use n and p to navigate between commits in a pull request.