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

Support HOCs that wrap & export component #48

Closed
ben-seed opened this issue Apr 9, 2018 · 4 comments
Closed

Support HOCs that wrap & export component #48

ben-seed opened this issue Apr 9, 2018 · 4 comments

Comments

@ben-seed
Copy link

ben-seed commented Apr 9, 2018

No documentation is produced if a component is wrapped before being exported, e.g. using redux connect.

I've tried using different resolvers but this doesn't fix the problem. I can see in the react-docgen codebase history that they have added support for HOCs, so I believe this limitation must be specific to this plugin.

@danielduan
Copy link
Member

can you paste a full file that I can test? we do support some HOCs, but definitely think we missed some edge cases.

@ben-seed
Copy link
Author

ben-seed commented Apr 17, 2018

TestComponent.jsx:

import React from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { mapStateToProps, mapDispatchToProps } from './testSelector';

const TestComponent = (props) => {
    const { text, onClick } = props;
    
    return (
        <div>
            <div>Text: {text}</div>
            <button onClick={onClick}>Button</button>
        </div>
    );
};

TestComponent.propTypes = {
    /** Text to display */
    text: PropTypes.string,
    /** Called on click */
    onClick: PropTypes.func
};

export default connect(mapStateToProps, mapDispatchToProps)(TestComponent);

testSelector.js:

export const mapStateToProps = (state, props) => ({
    text: 'hello'
});

export const mapDispatchToProps = (dispatch) => ({
    onClick: () => dispatch({ type: 'ON_CLICK' })
});

Note this issue occurs regardless of whether TestComponent is a pure functional or class component.

@mattapperson
Copy link

Also running into this issue with similar code

danielduan added a commit that referenced this issue Jun 17, 2018
danielduan added a commit that referenced this issue Jun 17, 2018
@danielduan danielduan reopened this Oct 23, 2019
@danielduan
Copy link
Member

Fixed in v3.2.0

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