Getting error
Error: Invalid hook call. Hooks can only be called inside of the body of a function component.
in a next.js environment when I try to use Zustand inside a utility function /utils/myfunction.js
as:
import { connectToDatabase } from "./mongodb"
import {userStore} from '@/utils/store'
export async function userSubs(userId, token) {
const { db } = await connectToDatabase()
const userSubs = userStore(state => state.userSubs)
const setGUserSubs = userStore(state => state.setGUserSubs)
...
how can I store/retrieve states with Zustand in a function or api then ? can't find a documentation about it