how to class component to functional components in react

I have some state and their setState also. but I wanna convert to the class component to the functional component but I don’t understand in setState how to do that.

state:

   constructor(posts) {
    super(posts);
    this.state = {
      data: posts,
      searchResultArray: [],
      cursor: {},
      currentResultIndex: 0,
    };
    this.onToggle = this.onToggle.bind(this);
  }

SetState:

plz, look this.setState my point is how to convert in functional components in the setState ?

onBtnClick = (e) => {
const { data, searchResultArray, currentResultIndex } = this.state;

let index = 0;
let tempObj = {};
if (e.target.id === "prev") {
  index = currentResultIndex - 1;
  tempObj = setSearchResult(data, searchResultArray, index);
  this.setState({
    data: tempObj.data,
    currentResultIndex: index,
    cursor: tempObj.cursor,
  });
}
if (e.target.id === "next") {
  index = currentResultIndex + 1;
  tempObj = setSearchResult(data, searchResultArray, index);
  this.setState({
    data: tempObj.data,
    currentResultIndex: index,
    cursor: tempObj.cursor,
  });
 }
};