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

Getting RangeError: Maximum call stack size exceeded with react-docgen@5.0.0-beta.1 #9

Closed
donysukardi opened this issue Nov 11, 2019 · 1 comment

Comments

@donysukardi
Copy link

donysukardi commented Nov 11, 2019

I added the custom resolver and i'm getting RangeError: Maximum call stack size exceeded when running react-docgen against function components and styled-components

const { findAllExportedComponentDefinitions } = require('react-docgen').resolver;
const annotationResolver = require('react-docgen-annotation-resolver');

const resolver = (ast, recast) => [
  ...findAllExportedComponentDefinitions(ast, recast),
  ...annotationResolver(ast, recast),
]

image

Sample component:

import React, { Component } from 'react';
import styled from 'styled-components';
import PropTypes from 'prop-types';

/**
 * General component description.
 */
const MyComponent = styled.button``;

MyComponent.propTypes = {
  /**
   * Description of prop "foo".
   */
  foo: PropTypes.number,
  /**
   * Description of prop "bar" (a custom validation function).
   */
  bar: function(props, propName, componentName) {
    // ...
  },
  baz: PropTypes.oneOfType([
    PropTypes.number,
    PropTypes.string
  ]).isRequired,
};

MyComponent.defaultProps = {
  foo: 42,
  bar: 21
};

/**
 * @component
 */
export default MyComponent;
@andrew-t-james
Copy link

andrew-t-james commented Jan 17, 2020

I am getting the same RangeError: Maximum call stack size exceeded with react-docgen@^5.0.0.
Possible break coming from https://github.com/reactjs/react-docgen/releases under the 5.0.0 section.

When we detect HOC react-docgen now assumes that the first argument to the HOC is the component. Previously we assumed the last argument is the component, but nearly all implementations of HOC which have multiple arguments have the component as the first argument.

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

No branches or pull requests

3 participants