Skip to content

Commit 004ec90

Browse files
authored
Merge pull request #128 from silx-kit/memo
Memoise `axiosConfig` object for safety
2 parents be388cd + 525db96 commit 004ec90

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/H5webApp.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useEffect, useState } from 'react';
1+
import React, { useEffect, useMemo, useState } from 'react';
22
import { App, getFeedbackMailto, H5GroveProvider } from '@h5web/app';
33
import { ServerConnection } from '@jupyterlab/services';
44

@@ -27,12 +27,17 @@ function H5webApp(props: { filePath: string }) {
2727
const { filePath } = props;
2828
const { baseUrl } = ServerConnection.makeSettings();
2929

30+
const axiosConfig = useMemo(
31+
() => ({ params: { file: filePath } }),
32+
[filePath]
33+
);
34+
3035
return (
3136
<div className="h5web-root">
3237
<H5GroveProvider
3338
url={`${baseUrl.endsWith('/') ? baseUrl.slice(0, -1) : baseUrl}/h5web`}
3439
filepath={filePath}
35-
axiosConfig={{ params: { file: filePath } }}
40+
axiosConfig={axiosConfig}
3641
>
3742
<TwoRenderApp />
3843
</H5GroveProvider>

0 commit comments

Comments
 (0)