react-responsive-accordion
react-responsive-accordion copied to clipboard
Cannot read property 'number' of undefined
Installing this package as well as the collapsible dependency fails to run.
I tried adding either react-collapsible 1.3.0 or the latest.
Anyupdates on this?
Have the same issue
I found this answer https://stackoverflow.com/questions/47494375/react-responsive-accordion-getting-uncaught-typeerror-cannot-read-property Maybe this helps
so I figured out a way to do it. I tried to do it directly in this repo, but encountered some error. If anyone can update the repo, that would be great! So there are actually two updates needed.
-
The update of the new prop type for higher react version. https://www.npmjs.com/package/prop-types
-
The update of react class. Read here for more info. https://teamtreehouse.com/community/i-get-this-error-react2defaultcreateclass-is-not-a-function-and-reactproptypes-is-undefined and here is how you rewrite the code.
After these two updates and change the code according to the tutorial. My app worked. Note, I just downloaded the source file and edit the file my self.
So here are the steps for a fix for now:
-
npm install --save prop-types for the newest prop type
-
npm install create-react-class --save for the newest create class
-
download the accordion.js file in /src. and replace the imports and the first line to be.
import React from 'react';
import Collapsible from 'react-collapsible';
import PropTypes from 'prop-types';
var createReactClass = require('create-react-class');
var Accordion = createReactClass({
-
import the accordion.js file by import Accordion from './Accordion.js'
-
Use it like how the example uses it. That's it :D Make sure you cite the author! :D
Can we have a new bundled version published instead? The src code already uses the updated prop-types
so we should just publish a new release to the registry to get this solved.
I had to also change all the React.PropTypes to jsut PropTypes in the Accordion.js file. Also in the component I changed var ResponsiveAccord = React.createClass({ to a component class.
I use accordions often and this is the only one that simply handles nested accordions. Is this still being maintained?
@NYCJacob since the last push to master was over 1 year ago, I think this is no longer relevant