Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When useFormStore is in a seperate file, it fails #179

Open
otherjohn opened this issue Feb 13, 2024 · 1 comment
Open

When useFormStore is in a seperate file, it fails #179

otherjohn opened this issue Feb 13, 2024 · 1 comment
Assignees
Labels
question Further information is requested

Comments

@otherjohn
Copy link

I am pretty sure this is an error on my part and not a bug.

when I have useFormStore in a component class, it works fine.
app.tsx

export const MortgageCalculator = ({
  rate
}: {
  rate?: string
}) => {
const calculatorForm = useFormStore<Inputs>({
    initialValues: inputInitialValues
  }); 
  // ... no errors and app runs fine.

But if I move the useFormStore to a store.ts file, I get the following error:
Uncaught TypeError: Cannot read properties of undefined (reading '__H') which looks like it
is triggered from useFormStore and something with preact/hooks

store.ts

const calculatorForm = useFormStore<Inputs>({
  initialValues: inputInitialValues
});
const breakdownSignal = useDeepSignal(breakdownInitialValues as Results)

const state = {calculatorForm, breakdownSignal};
export const useCalculatorStore = () => state;

and use it in the component like so:

app.tsx

export const MortgageCalculator = ({
  rate
}: {
  rate?: string
}) => {
const { calculatorForm, breakdownSignal } =  useCalculatorStore();
//... 

I am pretty sure this has something to so with my coding. Any help pointing out what I am doing wrong is very appreciated.

@fabian-hiller
Copy link
Owner

This is probably related to Preact. I recommend creating a issue there. I have never heard of this error and don't know what it is related to. Feel free to link me so I can help if necessary.

@fabian-hiller fabian-hiller self-assigned this Feb 13, 2024
@fabian-hiller fabian-hiller added the question Further information is requested label Feb 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants