I'm using hookstate to import an array which is going to be stored in state.
I've got this initial object - import { createState } from "@hookstate/core";
const initialState = {
exerciseDetails: [
{
exerciseID: 1,
exerciseName: "ex name",
exerciseDesc: "desc",
},
],
};
const exerciseState = createState(initialState);
export default exerciseState;
And then I'm accessing the object in my functional component as -
function CreateWorkoutScreen(){
const global = useState(exerciseState);
const { exerciseDetails } = global.get();
}
Which gives me the following error - TypeError: _this.child(key).get is not a function. (In '_this.child(key).get()', '_this.child(key).get' is undefined)
However, if I change my initial state to
const initialState = {
count: 0,
};
and access it in my functional component as
function CreateWorkoutScreen(){
const global = useState(exerciseState);
const { count } = global.get();
}
It works as expected. I'm guessing I'm not getting access to the array properly? Am I using the wrong syntax here?
Thanks in advance!!