1- import { useEffect , useState } from "react" ;
1+ import { useEffect , useRef , useState } from "react" ;
22import { useTranslation } from "react-i18next" ;
33import { useNavigate } from "react-router-dom" ;
44import {
@@ -34,7 +34,7 @@ function ScreenManager({
3434 initialState = null ,
3535} ) {
3636 const { t } = useTranslation ( "common" , { keyPrefix : "screen-manager" } ) ;
37- const [ saveWithoutClose , setSaveWithoutClose ] = useState ( false ) ;
37+ const saveWithoutCloseRef = useRef ( false ) ;
3838 const navigate = useNavigate ( ) ;
3939 const orientationOptions = [
4040 { title : "Vertikal" , "@id" : "vertical" } ,
@@ -258,7 +258,7 @@ function ScreenManager({
258258 } ;
259259
260260 const handleSubmitWithRedirect = ( ) => {
261- setSaveWithoutClose ( true ) ;
261+ saveWithoutCloseRef . current = true ;
262262 handleSubmit ( ) ;
263263 } ;
264264
@@ -268,8 +268,8 @@ function ScreenManager({
268268 displaySuccess ( t ( "success-messages.saved-screen" ) ) ;
269269 setSavingScreen ( false ) ;
270270
271- if ( saveWithoutClose ) {
272- setSaveWithoutClose ( false ) ;
271+ if ( saveWithoutCloseRef . current ) {
272+ saveWithoutCloseRef . current = false ;
273273
274274 if ( isSaveSuccessPost ) {
275275 navigate ( `/screen/edit/${ idFromUrl ( postData [ "@id" ] ) } ` ) ;
0 commit comments