modular-forms
modular-forms copied to clipboard
When useFormStore is in a seperate file, it fails
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.
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.