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.

Add support for composed component via HoC

See original GitHub issue

HoC is a good pattern but when I use it, component are not recognized as such.

import Wrapper from "./Wrapper"

const SidebarItem = (props) => {
  return (
    // ...
  )
})

export default Wrapper(SidebarItem)

Any idea how can we add support for this? I tried to add export { SidebarItem } but no luck 😕

Issue Analytics

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

github_iconTop GitHub Comments

2reactions
nhavarcommented, Sep 15, 2016

I noticed that react-docgen has a pull request recently to add an HOC resolver in the mix. https://github.com/reactjs/react-docgen/pull/124

2reactions
benknightcommented, Jul 27, 2016

My temporary solution is having a directory structure like this:

my-component
- my-component.jsx
- index.js
- readme.md

Where index.js serves as the entry point and the HoC wrapping happens there, thus leaving my-component.jsx unwrapped, and using that in the styleguide instead and manually passing it whatever props the HoC provided.

Read more comments on GitHub >

github_iconTop Results From Across the Web

React — Composing Higher-Order Components (HOCs)
To put it simply, a higher-order component is a function, ... We can create an HOC that handles and shares functionality to easily...
Read more >
Higher-Order Components - React
A higher-order component (HOC) is an advanced technique in React for reusing component logic. ... On mount, add a change listener to DataSource...
Read more >
What are the different ways in which React HOC components ...
React HOCA HOC can be imagined as a component which is passed to some function. ... The above way of using HOC allows...
Read more >
Using Recompose to write clean higher-order components
Learn how Recompose methods can help create cleaner HOCs and how it simplifies the development and organization of React components.
Read more >
Write better React, compose multiple functional HoCs, Higher ...
Write better React, compose multiple functional HoCs, Higher-Order Components. In a previous article, I wrote about the concept of chaining functions using ......
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