I found this code online and because I'm new to React wanted to know how to use it without getting this error.
this.props.children is not a function
From what I gather its listing to the body scroll position and trying to pass it as props to any React children its wrapped around. Am I correct ?
If so why the above error when I use it like below.
import React, {Component} from 'react';
import Nav from './nav';
import styles from '../../styles/header.scss';
import bgCover from '../../images/homeslider.jpg';
import Scroll from '../utils/scroll';
export default class Header extends Component{
    render(){
        return(
            <Scroll>
                <div id='header'>
                    <div className="container">
                        <img src={bgCover} id='bg-cover' alt="background-image" />
                        <div id="temp-text">HEADER</div>
                        <Nav />
                    </div>
                </div>
            </Scroll>
        )
    }
}
This is the scroll.js file
import React, {Component} from 'react';
export default class Scroll extends Component {
  constructor(props) {
    super(props);
    this.state = { scrollTop: 0,
                   scrollLeft: 0 };
    window.addEventListener('scroll', event => {
      this.setState({ scrollTop: document.body.scrollTop,
                      scrollLeft: document.body.scrollLeft});
    });
  }
  render() {
    return this.props.children(this.state.scrollTop, this.state.scrollLeft)
  }
}
 
     
    