roshanpr pro asked 6 years ago


Hi there, I am trying to use the scrollspy code from https://mdbootstrap.com/react/advanced/scrollspy/ My imports are below. import { Col, Container, Row, View, Mask, scrollSpySectionsOffset, ScrollSpyBox, ScrollSpyList, ScrollSpyListItem, ScrollSpyText} from 'mdbreact'; Getting the below error.   × TypeError: Cannot read property 'includes' of undefined ScrollRiseOfTechnology.componentDidMount src/components/pages/ScrollRiseOfTechnology.js:19
  16 | let scrollSpySections = this.scrollSpyText.getElementsByTagName('h4');
  17 | for (let i = 0; i < scrollSpySections.length; i++) {
  18 |   let currentOffsetTop = scrollSpySections[i].offsetTop - 16;
> 19 |   if (!scrollSpySectionsOffset.includes(currentOffsetTop)) {
  20 |     scrollSpySectionsOffset.push(currentOffsetTop);
  21 |   }
  22 | }
 

Mikołaj Smoleński staff answered 6 years ago


Hi, Please change import part to this:
import { Container, ScrollSpyBox, ScrollSpyList, ScrollSpyListItem, ScrollSpyText } from 'mdbreact';
const scrollSpySectionsOffset = [];
Regards


Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Resolved

Specification of the issue

  • ForumUser: Pro
  • Premium support: No
  • Technology: MDB React
  • MDB Version: -
  • Device: -
  • Browser: -
  • OS: -
  • Provided sample code: No
  • Provided link: Yes
Tags