pullstate icon indicating copy to clipboard operation
pullstate copied to clipboard

Error: Invalid hook call. Hooks can only be called inside of the body of a function component.

Open Lermatroid opened this issue 4 years ago • 0 comments

Hi,

I'm running into an issue where react says that the hook call is not valid. Here is my current code:

Component:


import React, {useState} from 'react';
import {ViewStore} from "../globalStores";

export default function RightPane(){

    const vs = ViewStore.useState(s => s.type);

    return(
        <div className="col-span-4">
            <TopBar />
        </div>
    )
}

Store:

import { Store } from "pullstate";

export const ViewStore = new Store({
    type: "main"
});

The exact error is the following and occurs when the viewStore is referenced at const vs = ViewStore.useState(s => s.type);:

Uncaught Error: Invalid hook call. Hooks can only be called inside of the body of a function component.

Thank you for the help!

Lermatroid avatar Jan 24 '22 15:01 Lermatroid