Closed Bug 1400404 Opened 5 years ago Closed 5 years ago

React should expect a boolean or a number as the JSON data

Categories

(DevTools :: JSON Viewer, enhancement, P3)

enhancement

Tracking

(firefox57 fix-optional, firefox58 fixed)

RESOLVED FIXED
Firefox 58
Tracking Status
firefox57 --- fix-optional
firefox58 --- fixed

People

(Reporter: Oriol, Assigned: abhinav.koppula)

Details

(Keywords: good-first-bug)

Attachments

(1 file)

http://searchfox.org/mozilla-central/rev/2c9a5993ac40ec1db8450e3e0a85702fa291b9e2/devtools/client/jsonview/components/main-tabbed-area.js#31

      json: PropTypes.oneOfType([
        PropTypes.string,
        PropTypes.object,
        PropTypes.array
      ])

http://searchfox.org/mozilla-central/rev/2c9a5993ac40ec1db8450e3e0a85702fa291b9e2/devtools/client/jsonview/components/json-panel.js#38

      data: PropTypes.oneOfType([
        PropTypes.string,
        PropTypes.array,
        PropTypes.object
      ])

But the JSON data can also be a boolean or a number, e.g.

    data:application/json,true
    data:application/json,1234

With --enable-debug-js-modules, they produce a warning in the console.

There is also null, but it seems that's already covered, probably by PropTypes.object.
Yep, good catch. Thanks for the report!

Honza
Keywords: good-first-bug
Priority: -- → P3
Hi Honza,
I was able to see that the following warnings go away with my patch applied.
Warning: Failed prop type: Invalid prop `json` supplied to `MainTabbedArea`.
    in MainTabbedArea  react-dev.js:22807
Warning: Failed prop type: Invalid prop `data` supplied to `JsonPanel`.
    in JsonPanel (created by MainTabbedArea)
    in MainTabbedArea

Can you take a look at my changes?
Comment on attachment 8911072 [details]
Bug 1400404 - Adding bool and number to list of PropTypes in Json-Panel.

https://reviewboard.mozilla.org/r/182542/#review188762

Works for me, thanks Abhinav!

Honza
Attachment #8911072 - Flags: review?(odvarko) → review+
Pushed by jodvarko@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/5d5d1d227104
Adding bool and number to list of PropTypes in Json-Panel. r=Honza
https://hg.mozilla.org/mozilla-central/rev/5d5d1d227104
Status: NEW → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 58
Assignee: nobody → abhinav.koppula
Product: Firefox → DevTools
You need to log in before you can comment on or make changes to this bug.