'Pass parameter to Parent from Child component through props function call

There is the parent component

const Parent = () => {
    const [searchText, setSearchText] = useState("");
    const onChangeQuery = (searchText) => {
        setSearchText(searchText);
    }
    return (
          <Child onChangeQuery={onChangeQuery} />
    )
}

And there is my child component

const Child = ({onChangeQuery}) => {
  useEffect(() => {
     onChangeQuery(someText);
  }, [someChangingVariable]);

  return (
      <h1>Hello World!<h1/>
  )
}

But i am getting Unhandled Runtime Error. TypeError: onChangeQuery is not a function.

I am not able to resolve it.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source