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.

No suitable component definition found

See original GitHub issue

image

I know this is not an issue specifically with react-styleguidist, for example: https://github.com/reactjs/react-docgen/issues/29

This happens in a lot of cases: when extending/composing components, or when using Redux and the connect() wrapper. For example, the following component is not recognised:

class Theme extends Component {
  // ...
  render() {
    // ...
  }
}

function mapStateToProps(state) {
  const variables = selectVariables(state.theme.name)
  return {
    variables: selectVariables(state.theme.name),
    styles: selectStyles(state.theme.name, variables)
  }
}

function mapDispatchToProps(dispatch) {
  return bindActionCreators(ThemeActions, dispatch)
}

export default connect(mapStateToProps, mapDispatchToProps)(Theme)

When using wrappers, we could use two files: _Theme.jsx (export “raw” component and use it for styleguide), and Theme (that uses wrappers etc.). However it would be great if it just work.

Any ideas on what needs to be done?

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:3
  • Comments:27 (18 by maintainers)

github_iconTop GitHub Comments

3reactions
sapegincommented, Jan 6, 2017

@jameslaneconkling This looks like a bug in react-docgen.

3reactions
jameslaneconklingcommented, Jan 5, 2017

Documenting this here in case it’s of help to anyone.

Returning a ternary from a stateless component threw the No suitable component definition found Error.

const Tooltip = ({ x, y, xOffset, yOffset, children }) => (
  typeof x === 'number' && typeof y === 'number' ? (
    <div
      style={{
        position: 'absolute',
        top: y + yOffset,
        left: x + xOffset,
        pointerEvents: 'none'
      }}
    >
      { children }
    </div>
  ) : (
    <noscript />
  )
);

Refactoring to use an if statement fixed it:

const Tooltip = ({ x, y, xOffset, yOffset, children }) => {
  if (typeof x === 'number' && typeof y === 'number') {
    return (
      <div
        style={{
          position: 'absolute',
          top: y + yOffset,
          left: x + xOffset,
          pointerEvents: 'none'
        }}
      >
        { children }
      </div>
    );
  }

  return <noscript />;
};
Read more comments on GitHub >

github_iconTop Results From Across the Web

Troubleshooting DSM Storybook error "No suitable ...
When trying to publish a Storybook story to DSM, you may encounter the following error: No suitable component definition found.
Read more >
Understanding Dash Custom Components Architecture
except the process complains: Error: No suitable component definition found . It appears this error comes from react-docgen, and that that tool ...
Read more >
vue-docgen-api: failed to parsed when exported component ...
[vue-docgen-loader] failed to parse the component file with docgen-api: No suitable component definition found on... To reproduce.
Read more >
How to use the react-docgen.resolver function in react ... - Snyk
Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately. Enable here ... 'No suitable...
Read more >
No suitable component definition found for ... - Bountysource
react-docgen can't find a component definition when the component is defined as a higher-order component: import React from 'react'; ...
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