Memo the sampling of functions
This commit is contained in:
parent
937458cd05
commit
ae2ee48511
|
@ -76,7 +76,9 @@ export const FunctionChart: React.FC<FunctionChartProps> = ({
|
||||||
chartSettings.count
|
chartSettings.count
|
||||||
);
|
);
|
||||||
type point = { x: number; value: result<Distribution, string> };
|
type point = { x: number; value: result<Distribution, string> };
|
||||||
let valueData: point[] = data1.map((x) => {
|
let valueData: point[] = React.useMemo(
|
||||||
|
() =>
|
||||||
|
data1.map((x) => {
|
||||||
let result = runForeign(fn, [x], environment);
|
let result = runForeign(fn, [x], environment);
|
||||||
if (result.tag === "Ok") {
|
if (result.tag === "Ok") {
|
||||||
if (result.value.tag == "distribution") {
|
if (result.value.tag == "distribution") {
|
||||||
|
@ -97,7 +99,9 @@ export const FunctionChart: React.FC<FunctionChartProps> = ({
|
||||||
value: { tag: "Error", value: errorValueToString(result.value) },
|
value: { tag: "Error", value: errorValueToString(result.value) },
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
});
|
}),
|
||||||
|
[environment, fn]
|
||||||
|
);
|
||||||
|
|
||||||
let initialPartition: [
|
let initialPartition: [
|
||||||
{ x: number; value: Distribution }[],
|
{ x: number; value: Distribution }[],
|
||||||
|
|
Loading…
Reference in New Issue
Block a user