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

Fix some react warnings #5877

Merged
merged 1 commit into from Aug 14, 2018
Merged

Fix some react warnings #5877

merged 1 commit into from Aug 14, 2018

Conversation

willdurand
Copy link
Member

@willdurand willdurand commented Aug 8, 2018

Fix mozilla/addons#12172


This PR aims at fixing most of the issues displayed when running yarn amo:dev.

The InfoDialog warnings are fixed in #5880

@codecov-io
Copy link

codecov-io commented Aug 8, 2018

Codecov Report

Merging #5877 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    mozilla/addons-frontend#5877      +/-   ##
==========================================
+ Coverage   97.72%   97.73%   +<.01%     
==========================================
  Files         229      229              
  Lines        5859     5860       +1     
  Branches     1122     1122              
==========================================
+ Hits         5726     5727       +1     
  Misses        118      118              
  Partials       15       15
Impacted Files Coverage Δ
src/amo/components/Addon/index.js 100% <ø> (ø) ⬆️
src/core/components/InstallSwitch/index.js 100% <ø> (ø) ⬆️
src/amo/components/LandingPage/index.js 100% <ø> (ø) ⬆️
src/core/installAddon.js 100% <ø> (ø) ⬆️
src/core/components/InstallButton/index.js 100% <ø> (ø) ⬆️
src/amo/components/LanguageTools/index.js 100% <100%> (ø) ⬆️
src/core/middleware/security.js 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 281659d...856d882. Read the comment docs.

@@ -60,8 +60,8 @@ const slugIsPositiveID = (slug) => {
export class AddonBase extends React.Component {
static propTypes = {
config: PropTypes.object,
RatingManager: PropTypes.element,
addon: PropTypes.object.isRequired,
RatingManager: PropTypes.func,
Copy link
Member Author

Choose a reason for hiding this comment

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

This is pretty common and there is an issue here: facebook/react#5143. TL;DR: no type for what we want to do, here we need a function though (because we apply compose() to the base component).

<Tr>
: Array.from(Array(50)).map((_, i) => (
// eslint-disable-next-line react/jsx-indent, react/no-array-index-key
<Tr key={`LoadingText-${i}`}>
Copy link
Member Author

Choose a reason for hiding this comment

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

We need to specify keys all the time when we use map (or .fill but it is not exactly the same thing).

Copy link
Contributor

Choose a reason for hiding this comment

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

yeh i think any child in an array or iterator we do, right?

Copy link
Member Author

Choose a reason for hiding this comment

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

yep

@@ -21,7 +21,7 @@ export function getNoScriptStyles(
`src/${appName}/noscript.css`,
);
try {
return fs.readFileSync(cssPath);
return fs.readFileSync(cssPath, 'utf8');
Copy link
Member Author

Choose a reason for hiding this comment

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

Don't recall the error but we should really pass the encoding in readFileSync()

@willdurand willdurand changed the title [WIP] Fix server warnings Fix some react warnings Aug 9, 2018
Copy link
Contributor

@rebmullin rebmullin left a comment

Choose a reason for hiding this comment

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

@willdurand, looks 👍 Thanks for doing this.

@@ -60,8 +60,8 @@ const slugIsPositiveID = (slug) => {

export class AddonBase extends React.Component {
static propTypes = {
RatingManager: PropTypes.element,
addon: PropTypes.object.isRequired,
RatingManager: 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.

hmm, didn't expect that but seems this is ok..

<Tr>
: Array.from(Array(50)).map((_, i) => (
// eslint-disable-next-line react/jsx-indent, react/no-array-index-key
<Tr key={`LoadingText-${i}`}>
Copy link
Contributor

Choose a reason for hiding this comment

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

yeh i think any child in an array or iterator we do, right?

@rebmullin
Copy link
Contributor

rebmullin commented Aug 14, 2018

actually I am seeing this still when I run disco:

Warning: Failed prop type: The prop `handleGlobalEvent` is marked as required in `DiscoPaneBase`, but its value is `undefined`.
[1]     in DiscoPaneBase
[1]     in Translate(DiscoPaneBase)
[1]     in Connect(Translate(DiscoPaneBase))
...
[1] Warning: Failed prop type: The prop `hasAddonManager` is marked as required in `AddonBase`, but its value is `undefined`.
[1]     in AddonBase
[1]     in WithInstallHelpers
...
[1] Warning: Failed prop type: The prop `status` is marked as required in `AddonBase`, but its value is `undefined`.
[1]     in AddonBase
[1]     in WithInstallHelpers
[1]     in Connect(WithInstallHelpers)
...

are you not seeing these?

@willdurand
Copy link
Member Author

I'll follow up with the disco pane, which is being modified in other PRs.

@willdurand willdurand merged commit 85113ae into master Aug 14, 2018
@willdurand willdurand deleted the fix-server-invalid-props branch August 14, 2018 04:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants