This is my sorting.js file and I am trying to access the resetArray of this file from a onClick button listener of App.js. But unable to do it. Please help.
export default class sorting extends React.Component {
constructor() {
super();
this.state = {
array: [],
};
}
resetArray() {
var array = [];
for (let i = 0; i < 80; i++) {
array.push(this.randomNumber(10, 350));
}
this.setState({ array });
}
}
This is my App.js file
import React from 'react';
import Sorting from './sorting/sorting.js';
class App extends React.Component {
render() {
return (
<div>
<Sorting />
<button onClick={() => this.resetArray()}>
</div>
)
}
}