mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-15 15:44:45 -04:00
Note Loading Boundary: Replace redirect with refetch from API (#2275)
This commit is contained in:
parent
fa53bccb03
commit
f2ed9d4453
6 changed files with 54 additions and 28 deletions
|
@ -4,7 +4,7 @@
|
|||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
import { useAsync } from 'react-use'
|
||||
import { useAsyncFn } from 'react-use'
|
||||
import { getNote } from '../../../../api/notes'
|
||||
import { setNoteDataFromServer } from '../../../../redux/note-details/methods'
|
||||
import { useSingleStringUrlParameter } from '../../../../hooks/common/use-single-string-url-parameter'
|
||||
|
@ -15,10 +15,10 @@ import type { AsyncState } from 'react-use/lib/useAsyncFn'
|
|||
*
|
||||
* @return An {@link AsyncState async state} that represents the current state of the loading process.
|
||||
*/
|
||||
export const useLoadNoteFromServer = (): AsyncState<void> => {
|
||||
export const useLoadNoteFromServer = (): [AsyncState<void>, () => void] => {
|
||||
const id = useSingleStringUrlParameter('noteId', undefined)
|
||||
|
||||
return useAsync(async () => {
|
||||
return useAsyncFn(async () => {
|
||||
if (id === undefined) {
|
||||
throw new Error('Invalid id')
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue