Fixed render issue with createFormulaPreview

This commit is contained in:
thepaperpilot 2023-04-22 19:54:12 -05:00
parent a59f77aa6d
commit d5a7ba4af2

View file

@ -462,13 +462,13 @@ export function createFormulaPreview(
formula: GenericFormula, formula: GenericFormula,
showPreview: Computable<boolean>, showPreview: Computable<boolean>,
previewAmount: Computable<DecimalSource> = 1 previewAmount: Computable<DecimalSource> = 1
): ComputedRef<CoercableComponent> { ) {
const processedShowPreview = convertComputable(showPreview); const processedShowPreview = convertComputable(showPreview);
const processedPreviewAmount = convertComputable(previewAmount); const processedPreviewAmount = convertComputable(previewAmount);
if (!formula.hasVariable()) { if (!formula.hasVariable()) {
throw new Error("Cannot create formula preview if the formula does not have a variable"); throw new Error("Cannot create formula preview if the formula does not have a variable");
} }
return computed(() => { return jsx(() => {
if (unref(processedShowPreview)) { if (unref(processedShowPreview)) {
const curr = formatSmall(formula.evaluate()); const curr = formatSmall(formula.evaluate());
const preview = formatSmall( const preview = formatSmall(
@ -479,7 +479,7 @@ export function createFormulaPreview(
) )
) )
); );
return jsx(() => ( return (
<> <>
<b> <b>
<i> <i>
@ -487,8 +487,8 @@ export function createFormulaPreview(
</i> </i>
</b> </b>
</> </>
)); );
} }
return formatSmall(formula.evaluate()); return <>{formatSmall(formula.evaluate())}</>;
}); });
} }