react-responsive-accordion icon indicating copy to clipboard operation
react-responsive-accordion copied to clipboard

Cannot read property 'number' of undefined

Open vladnicula opened this issue 7 years ago • 7 comments

Installing this package as well as the collapsible dependency fails to run.

I tried adding either react-collapsible 1.3.0 or the latest.

vladnicula avatar Nov 10 '17 09:11 vladnicula

Anyupdates on this?

kailashvele avatar Dec 18 '17 08:12 kailashvele

Have the same issue

vaske avatar Dec 19 '17 10:12 vaske

I found this answer https://stackoverflow.com/questions/47494375/react-responsive-accordion-getting-uncaught-typeerror-cannot-read-property Maybe this helps

noashka avatar Dec 26 '17 13:12 noashka

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.

  1. The update of the new prop type for higher react version. https://www.npmjs.com/package/prop-types

  2. 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:

  1. npm install --save prop-types for the newest prop type

  2. npm install create-react-class --save for the newest create class

  3. 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({
  1. import the accordion.js file by import Accordion from './Accordion.js'

  2. Use it like how the example uses it. That's it :D Make sure you cite the author! :D

xiaofanwu avatar Feb 12 '18 04:02 xiaofanwu

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.

armand1m avatar Apr 29 '18 13:04 armand1m

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 avatar Nov 07 '18 00:11 NYCJacob

@NYCJacob since the last push to master was over 1 year ago, I think this is no longer relevant

vladnicula avatar Nov 09 '18 07:11 vladnicula