I have the next problem, trying to call a function from a functional component, like shared in class components.
My test code is:
import React, { useState } from 'react'
export const TestShared = () => {
const [number, setNumber] = useState(0)
const increase = () => {
return setNumber(prevValue => prevValue + 1)
}
const getNumber = () => {
return number
}
}
In another file I import TestShared and trying to call the functions like TestShared.increase() or TestShared.getNumber() but of course is undefined.
How can I achieve this without using useContext? If there is any possible way.
Thank you!