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.

Error with Stateless Components

See original GitHub issue

Has anyone else had an issue with getting stateless functional components to load?

I am getting this error:

Error when parsing src/scripts/components/Inputs/Button.jsx RangeError: Maximum call stack size exceeded

This my styleguide.config,js

/* global module, require, process, __dirname */

const path = require('path');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
const docgen = require('react-docgen');

module.exports = {
    title: 'Components',
    defaultExample: true,
    serverPort: 5000,
    showCode: true,
    skipComponentsWithoutExample: true,
    getExampleFilename: componentpath => componentpath.replace(/\.jsx$/, '.examples.md'),
    resolver: docgen.resolver.findAllComponentDefinitions,
    sections: [
        {
            name: 'Inputs',
            components: './src/scripts/components/Inputs/**/*.jsx',
        },
        {
          name: 'Navigation',
          components: './src/scripts/components/NavBar/**/*.jsx',
        },
        {
          name: 'Layout',
          components: './src/scripts/components/layout/**/*.jsx',
        },
      ],
    updateWebpackConfig: function(webpackConfig, env) {
        const dir = path.join(__dirname, 'src');

        webpackConfig.module.loaders.push(
          {
              test: /\.jsx?$/,
              exclude: /node_modules/,
              include: path.join(__dirname, 'src'),
              loader: 'babel'
          },
          {
              test: /\.css$/,
              include: dir,
              loader: 'style!css?modules&importLoaders=1'
          },
          {
              test: /\.scss$/,
              include: path.join(__dirname, 'src'),
              loader: ExtractTextPlugin.extract(
                'style-loader',
                'css-loader?' +
                'modules&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]' +
                '!sass')
          },
          {
              test: /\.less$/,
              exclude: /node_modules/,
              loader: 'style!css!less'
          },
          {
              test: /\.(png|jpg|jpeg|gif|svg|woff|woff2)$/,
              include: path.join(__dirname, 'src'),
              loader: 'url?limit=8192'
          }
        );

        webpackConfig.plugins.push(
          new ExtractTextPlugin('css/app.css')
        );

        return webpackConfig;
    }
};

Issue Analytics

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

github_iconTop GitHub Comments

2reactions
jeffkamocommented, Jan 27, 2018

Well, in setting up a pared down example for you, @n1313, I discovered what was causing this issue in my project.

It turns out our project was also depending on react-docgen and was using it into our styleguidist.config.js

const DocGen = require('react-docgen') // <-- v2.15.0 from our local package.json

// ...

module.exports = {
    // ...
    resolver: DocGen.resolver.findAllComponentDefinitions, // <-- this was the problem
    // ...
}

Removing the resolver key from this module.export fixes the problem, and my components appear to work better.

Cheers, and thanks!

Edit!

Instead of just removing the resolver (because we need it), updating react-docgen to 3.0.0-beta9 (which is currently used by react-styleguidist) also fixed this issue.

1reaction
SimonSomlaicommented, Mar 7, 2019

Just removing react-docgen didn’t work for me. But ;

downgrading styleguidist from v9 to ^8.0.6 AND removing react-docgen from package.json solved the problem for me.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Stateless component in react with typescript error 'Type ...
I'm trying to build a stateless component in react with typescript, I have a long error message that ends by Type 'ObjectType[string]' is ......
Read more >
React 16: Stateless function components cannot be given refs ...
I'm having this issue when using redux, which wraps another wrapper: DragDropContext(HTML5Backend)(connect(mapStateToProps, mapDispatchToProps, ...
Read more >
Stateless Component - Cloud Computing Patterns
Stateless Component. State is handled external of application components to ease their ... In case of failure, this information may even be lost....
Read more >
Handle errors in React components like a pro
In order to use Error Boundary in Functional Component, I use react-error-boundary. import * as React from 'react' import ...
Read more >
How I write React stateless functional components - moox.io
This problem is basically not related to React component but more “how do you define your arguments in functions”. I will stick to...
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