Skip to content
This repository was archived by the owner on Nov 20, 2020. It is now read-only.
This repository was archived by the owner on Nov 20, 2020. It is now read-only.

defaultValue value without double quotes #93

Open
@adammockor

Description

@adammockor

There is \\"defaultValue\\": { value: 123 } without without double quotes around value key in your test snapshots. Do you know why and is there a way to add " around value key?

I ran to strange bug because of this and that can be fixable here probably.
Let's say I have component Note which has docgenInfo like this.

Note.__docgenInfo = {
    "description": "",
    "displayName": "Note",
    "props": {
      "type": {
        "defaultValue": {
          value: "info"
        },
        "description": "",
        "name": "type",
        "required": false,
        "type": {
          "name": "\"error\" | \"info\" | undefined"
        }
      }
    }
  };

Then I passing this Note.__docgenInfo in Note.mdx file to component which generate table from it. There it goes wrong because I will get "defaultValue": null instead of "defaultValue": { value: "info" }.

If I do this Note.__docgenInfo = JSON.parse(JSON.stringify(Note.__docgenInfo)); before passing to MDX, I will get "defaultValue": { "value": "info" } which is what I want.

I know there must be some problem with MDX parser discarding that { value: "info" }, but if I can get valid JSON object in __docgenInfo from this loader, that is probably better.

What do you think? I tried to hack the code around to get there that quotes, but without success.

Thank you for your time.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions