mirror of
https://github.com/sasjs/server.git
synced 2026-01-03 21:10:05 +00:00
fix(web): infinite call to api end point fixed
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import React, { useState, useEffect } from 'react'
|
import React, { useState, useEffect, useCallback } from 'react'
|
||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
import { useLocation } from 'react-router-dom'
|
import { useLocation } from 'react-router-dom'
|
||||||
|
|
||||||
@@ -41,8 +41,14 @@ const SideBar = (props: any) => {
|
|||||||
const baseUrl = window.location.origin
|
const baseUrl = window.location.origin
|
||||||
const classes = useStyles()
|
const classes = useStyles()
|
||||||
|
|
||||||
|
const { setSelectedFilePath } = props
|
||||||
const [directoryData, setDirectoryData] = useState<TreeNode | null>(null)
|
const [directoryData, setDirectoryData] = useState<TreeNode | null>(null)
|
||||||
|
|
||||||
|
const setFilePathOnMount = useCallback(() => {
|
||||||
|
const queryParams = new URLSearchParams(location.search)
|
||||||
|
setSelectedFilePath(queryParams.get('filePath'))
|
||||||
|
}, [location.search, setSelectedFilePath])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
axios
|
axios
|
||||||
.get(`/SASjsApi/executor`)
|
.get(`/SASjsApi/executor`)
|
||||||
@@ -54,9 +60,8 @@ const SideBar = (props: any) => {
|
|||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
console.log(err)
|
console.log(err)
|
||||||
})
|
})
|
||||||
const queryParams = new URLSearchParams(location.search)
|
setFilePathOnMount()
|
||||||
props.setSelectedFilePath(queryParams.get('filePath'))
|
}, [setFilePathOnMount])
|
||||||
})
|
|
||||||
|
|
||||||
const handleSelect = (node: TreeNode) => {
|
const handleSelect = (node: TreeNode) => {
|
||||||
if (!node.children.length) {
|
if (!node.children.length) {
|
||||||
@@ -65,7 +70,7 @@ const SideBar = (props: any) => {
|
|||||||
'',
|
'',
|
||||||
`${baseUrl}/#/SASjsDrive?filePath=${node.relativePath}`
|
`${baseUrl}/#/SASjsDrive?filePath=${node.relativePath}`
|
||||||
)
|
)
|
||||||
props.setSelectedFilePath(node.relativePath)
|
setSelectedFilePath(node.relativePath)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user