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.

Card component throws error

See original GitHub issue

Issue description

Card component throws errors.

  • components: Card
  • reactstrap version ^4.8.0
  • react version ^16.2.0
  • bootstrap version v4.0.0-alpha.2

What is happening?

When I use Card component with only CardImg, I don’t get any errors

import React, { Component } from 'react';
import { Card, Button, CardImg, CardTitle, CardText, CardDeck, CardSubtitle, CardBody } from 'reactstrap';

class MoviesIndex extends Component {

    render() {
        return (
            <CardDeck>
                <Card>
                    <CardImg top width="100%" src="" alt="Movie Poster" />
                </Card>
            </CardDeck>
        );
    }
}

export default MoviesIndex;

Steps to reproduce issue

But when I use this version of Component instead:

import React, { Component } from 'react';
import { Card, Button, CardImg, CardTitle, CardText, CardDeck, CardSubtitle, CardBody } from 'reactstrap';

class MoviesIndex extends Component {

    render() {
        return (
            <CardDeck>
                <Card>
                    <CardImg top width="100%" src="" alt="Movie Poster" />
                    <CardBody>
                        <CardTitle>Card title</CardTitle>
                        <CardSubtitle>Card subtitle</CardSubtitle>
                        <CardText>This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</CardText>
                        <Button>Button</Button>
                    </CardBody>
                </Card>
            </CardDeck>
        );
    }
}

export default MoviesIndex;

Error message in console

screenshot from 2017-12-06 22-11-46

package.json

{
  "name": "client",
  "version": "1.0.0",
  "main": "index.js",
  "scripts": {
    "start": "node ./node_modules/webpack-dev-server/bin/webpack-dev-server.js",
    "test": "mocha --compilers js:babel-core/register --require ./test/test_helper.js --recursive ./test",
    "test:watch": "npm run test -- --watch"
  },
  "devDependencies": {
    "babel-core": "^6.2.1",
    "babel-loader": "^6.2.0",
    "babel-preset-es2015": "^6.1.18",
    "babel-preset-react": "^6.1.18",
    "chai": "^3.5.0",
    "chai-jquery": "^2.0.0",
    "jquery": "^2.2.1",
    "jsdom": "^8.1.0",
    "mocha": "^2.4.5",
    "react-addons-test-utils": "^0.14.7",
    "webpack": "^1.12.9",
    "webpack-dev-server": "^1.14.0"
  },
  "dependencies": {
    "axios": "^0.17.1",
    "babel-preset-stage-1": "^6.1.18",
    "lodash": "^3.10.1",
    "react": "^16.2.0",
    "react-dom": "^16.2.0",
    "react-redux": "^5.0.6",
    "react-router": "^4.2.0",
    "react-transition-group": "^2.2.1",
    "reactstrap": "^4.8.0",
    "redux": "^3.7.2",
    "redux-promise": "^0.5.3"
  }
}

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
androidandcommented, Jan 6, 2018

Not sure what was wrong but latest version after uninstalling and installing seems to work fine!

1reaction
TheSharpieOnecommented, Dec 7, 2017

The documentation site has the latest release (reactstrap v5.0.0-alpha.4), you are using reactstrap v4.8.0. The components you are using are not available in v4.8.0, you need to update or use the equivalent components (CardBody -> CardBlock) #195 would have helped with this by having a public documentation of the version you are using. For now, you can run the docs locally by cloning this project and checking out the 4.8.0 tag and npm install then npm start.

5.0.0-alpha.4 Demo: https://stackblitz.com/edit/react-rnchuj?embed=1&file=Hello.js 4.8.0 Demo: https://stackblitz.com/edit/react-axflbx?file=Hello.js (stackblitz seems to be having some issues with reactstrap-tether… don’t know why)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Reactstrap Card component throws error - Stack Overflow
This type of error usually results from something not being exported correctly or something being null/undefined due to data missing, etc. This ...
Read more >
Lightning:card markup Error - Salesforce Developer Community
For challenge "Create a Lightning Component", I am getting the error listed below. I was able to get through all of the other...
Read more >
Blade Component Reusability Issue, getting error - Laracasts
Hello, I have created blade component for bootstrap card and when I try to use it twice I get the error: Cannot declare...
Read more >
[Solved]-Reactstrap Card component throws error-Reactjs
Bit build throws an error if a component uses external library like Material UI? Formik hooks "useField" throws error stating that the component...
Read more >
Cards - Bootstrap
Bootstrap's cards provide a flexible and extensible content container with multiple ... to those components is available as modifier classes for cards.
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