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

defaultValue value without double quotes #93

Open
adammockor opened this issue Mar 29, 2020 · 0 comments
Open

defaultValue value without double quotes #93

adammockor opened this issue Mar 29, 2020 · 0 comments

Comments

@adammockor
Copy link
Contributor

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant