question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Redux connect support

See original GitHub issue

Hi,

I have a React/Redux app that I’d like to document. With redux, I use the connect() function.

But when I use it, react-docgen cannot find a valid component in my file.

This works:

const Contributors = React.createClass({...});
export default Contributors;

This does not:

const Contributors = React.createClass({...});
const mapStateToProps = (state) => {
  return { contributors: state.contributors }
}
export default connect(mapStateToProps)(Contributors);

I found a workaround by appending this to the end of file, but I don’t know if it will not break something later:

module.exports = Contributors;

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:5
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

4reactions
rtsaocommented, Jun 3, 2016

Yeah, actually I think this should be very doable.

export default hoc1(Component);

export default hoc1(arg1a, arg1b)(Component);

export default hoc2(arg2b, arg2b)(
  hoc1(arg1a, arg2a)(Component)
);

export default hoc3(arg3a, arg3b)(
  hoc2(arg2b, arg2b)(
    hoc1(arg1a, arg2a)(Component)
  )
);

// etc...

When I get a chance I’ll give it a go and submit a PR

2reactions
fklingcommented, Jun 1, 2016

@rtsao:

I’ve added support for single unary higher-order-components in my personal fork

That seems very reasonable to me, and I think it would even make sense to expand this to non-unary functions. The other arguments could be included in the output as well, as far as possible. Happy to review that PR 😃

@maximelebastard As an intermediate solution, if you can use the findAllComponentDefinitions resolver, which looks for all component definitions, not just the exported ones.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Connect | React Redux
The connect() function connects a React component to a Redux store. It provides its connected component with the pieces of the data it...
Read more >
React Redux connect(): When and how to use it
In this guide, we've covered when and how to use the React Redux connect() API to create container components that are connected to...
Read more >
React Redux Tutorials - 18 - connect - YouTube
React Redux Tutorials - 18 - connect ; Courses - https://learn.codevolution.dev/ ; Support UPI - https:// support.codevolution.dev/ ;
Read more >
How, When, and Why to Connect() in React JS - Medium
connect ()method just provides a way for the user to connect the component to the redux store. It provides its connected component with...
Read more >
5 Ways to Connect Redux Actions - Bene Studio
mapDispatchToProps […] If an object is passed, each function inside it is assumed to be a Redux action creator. An object with the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found