Coder Social home page Coder Social logo

Comments (4)

fkling avatar fkling commented on April 27, 2024

Thinking about it more, I will have to check again if it is really a bug. It might also be that the computed: true field should indicate that value is the source instead of the real value.

But even then, it's probably better to leave value empty and have the source in raw.

from react-docgen.

joaomilho avatar joaomilho commented on April 27, 2024

I have the same problem, although my example is simpler. Given the following code:

export default function Tooltip () { ... }

Tooltip.arrows = ['up', 'down', 'left', ...];

Tooltip.propTypes = {
  arrow: PropTypes.oneOf(Tooltip.arrows)
};

And this generates the following JSON:

{
  arrow:
   { type: { name: 'enum', computed: true, value: 'Tooltip.arrows' },
     required: false,
     description: '' }
}

from react-docgen.

joshfarrant avatar joshfarrant commented on April 27, 2024

Any further thoughts on this? I've recently run into the same problem with the following:

const KIND = {
  PRIMARY: 'primary',
  SECONDARY: 'secondary'
};

// ...

static propTypes = {
  kind: PropTypes.oneOf(Object.values(KIND))
};

I'd expect this:

{
  "kind": {
    "type": {
      "name": "enum",
      "value": [{
        "value": "'primary'",
        "computed": false
      }, {
        "value": "'secondary'",
        "computed": false
      }]
    },
    "required": false,
    "description": "",
    "defaultValue": {
      "value": "'primary'",
      "computed": false
    }
  }
}

However I'm getting this:

{
  "kind": {
    "type": {
    "name": "enum",
    "computed": true,
    "value": "Object.values(KIND)"
  },
    "required": false,
    "description": "",
    "defaultValue": {
      "value": "'default'",
      "computed": false
    }
  }
}

Is there a workaround for this, or a fix in the works? If not, I'd be happy to look at submitting a PR to address this, if you could point me in the right direction.

from react-docgen.

dmitry-zaets avatar dmitry-zaets commented on April 27, 2024

related to #153 and #122

from react-docgen.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.