React waddo udaw....

හෙළයෙක්

Well-known member
  • Apr 26, 2014
    48,476
    98,427
    113
    Man mobile eken inne try out karala balanna widhihak na udin pallen balala kiwwe.. Uda ekkenek solution eka dala thiyenawa neda
    Eka AI ekakin Aran thiyene. oke case eka empty array eka thama. Karala balapanko. Dom eken component eka re render karanawa oya seen eke. useRef ekata decency thiyala Oka block Karana oni
     
    • Like
    Reactions: jennt

    හෙළයෙක්

    Well-known member
  • Apr 26, 2014
    48,476
    98,427
    113
    Na machan stackblitz eke try karala balanna empty array useEffect ekak athule log ekak daala
    Eka hari eka eka para thama. Eka mama danawa. Mekata Oka empty thibama digatama update wenawa. Oya component eka re render wenawa digatama.

    Na machan stackblitz eke try karala balanna empty array useEffect ekak athule log ekak daala
    hari mama liyala thiyena eka confuse thama. empty array eka nisa loop wenawa kiyalane kiyala thiyene. Eka bageta kiyala thiyene.

    component 2kak aragena parent eke depency ekak maintain Karana wenwa render unadada nedda kiyana eka child eke. Eka status ekak kohoma hari eliyen manage wena Oni document eka update wena nisa. Fetch eka eliyata gatha nan hari
    ------ Post added on Mar 2, 2024 at 9:34 PM
     
    • Like
    Reactions: jennt

    gamerlk

    Well-known member
  • Dec 23, 2023
    4,799
    6,565
    113
    Ne eka thama oke case eka. Useref ekath Ekka Oka run wenawa. mulin 2 parak Oka run wenwa ita passe loop wenwa. Dev eke wene strict mode ain karama ok Eth solution eka nan useRef eka check karana eka. eka decenciey ekak widiyata dala null check karana eka.

    https://stackoverflow.com/questions...twice-even-if-an-empty-array-is-used-as-an-ar
    See this is what I too said 👇👇👇👇
    Naththam useEffect with empty array run wenne eka parai.. Methana wenne ara lib eken document eka aaye aaye load wenawa react context eken eliye..
     

    gamerlk

    Well-known member
  • Dec 23, 2023
    4,799
    6,565
    113
    Oka waradi ne theory eke hatiyata. Mama kiwe bageta. Follow karagana Yana anik reply tika
    I'm not talking about what is inside the useEffect in this particular case. I'm talking about the comment where you said empty dependency array will cause the effect to run in each render.

    a useEffect runs each render when there is no dependency array is provided, not when there is an empty dependency array.

    eka waradi nm react docs th waradi wenna one :rofl:
    https://react.dev/reference/react/useEffect#my-effect-runs-after-every-re-render

    PS: If you tried to say that useEffect runs after each render even if an empty array is provided because of the logic inside useEffect, no worries. I just wanted to correct that comment as in the way it was written, it was perceived as a generalized comment.
     

    හෙළයෙක්

    Well-known member
  • Apr 26, 2014
    48,476
    98,427
    113
    I'm not talking about what is inside the useEffect in this particular case. I'm talking about the comment where you said empty dependency array will cause the effect to run in each render.

    a useEffect runs each render when there is no dependency array is provided.

    eka waradi nm react docs th waradi wenna one :rofl:
    https://react.dev/reference/react/useEffect#my-effect-runs-after-every-re-render
    Oka waradi kiyala mama kiwe ne.

    Mage answer ekath waradi ne mama meke useeffect eka theory eka anuwa re render wena be kiyana eka danawa e unata eka empty thiyala epa oya inside thiyena eken full ekama aye re create wenawa e nisa eka depency ekak dala block Karana kiyana eka kiwe, dewni answer eka balana. Mama liyapu eka confuse athi bageta kiyala thiyena nisa.
    Oka dev eke nisa strict ekenuth aulak wenawa deparak run wenakota.
    Interview ekaka magen ahuwoth dena urhara dena Oni ne ne me wage bug ekak fix karagana direction eka dunama athi ne. Eka thama mama Kare.
     
    • Like
    Reactions: jennt

    gamerlk

    Well-known member
  • Dec 23, 2023
    4,799
    6,565
    113
    Mage answer ekath waradi ne mama meke useeffect eka theory eka anuwa re render wena be kiyana eka danawa e unata eka empty thiyala epa oya inside thiyena eken full ekama aye re create wenawa e nisa eka depency ekak dala block Karana kiyana eka kiwe, dewni answer eka balana. Mama liyapu eka confuse athi bageta kiyala thiyena nisa.
    I added a PS to my initial comment. No worries :) 👇
    PS: If you tried to say that useEffect runs after each render even if an empty array is provided because of the logic inside useEffect, no worries. I just wanted to correct that comment as in the way it was written, it was perceived as a generalized comment.
     

    හෙළයෙක්

    Well-known member
  • Apr 26, 2014
    48,476
    98,427
    113
    I added a PS to my initial comment. No worries :) 👇
    Hari hari mama Oka analysis karala expand karala kiwe ne thama Eth wena de simply first comment ekema kiwa. Component ekama aye re render wenawa kiyala. Error ekak fix karagana oya tika athi.

    @gamerlk 👇👇
    Pahala ref eka useeffect eken maru karama component ekama change wenawa. Ethakota aye parak useeffect trigger wenawa
    ------ Post added on Mar 2, 2024 at 10:24 PM
     
    • Like
    Reactions: jennt and gamerlk

    gamerlk

    Well-known member
  • Dec 23, 2023
    4,799
    6,565
    113
    Hari hari mama Oka analysis karala expand karala kiwe ne thama Eth wena de simply first comment ekema kiwa. Component ekama aye re render wenawa kiyala. Error ekak fix karagana oya tika athi.
    hari hari bn mn eka thama ara PS ekakuth dala kiwe uba kiyanna hadapu de mata theruna kiyala :D :D

    kalin dala thibuna eka kiyewwama wena therumak awe.
     

    poopoo

    Well-known member
  • Nov 18, 2021
    5,766
    11,419
    113
    දැනුයි පොඩ්ඩක් බලන්න හම්බුනේ.. ඕපියා පැත්ත පලාතේ නෑ නේද උත්තරයක් දෙන්න :oo:
    ජෙමිනිගේ code එක වැඩ කරනවා දැකලා pressure වැඩි වෙලා
    Get well soon OP @jennt :(

    What The Reaction GIF by MOODMAN
     

    හෙනයා

    Well-known member
  • May 23, 2014
    16,733
    16,835
    113
    Kottawa
    Mama innawa dapan Mata balagana Oni Mata waradunada kiyala. 😔

    මේකේ මූ කරන්නේ pdftron lib එකෙන් PDF files edit කරල ඒක කොහෙටහරි upload කරන එකක්... මේකෙ documentLoaded event එක trigger වෙනවා මුලදි & මේකෙදි 👇
    Code:
    instance.UI.loadDocument(url, {extension: 'pdf'});

    එතකොට කොහොමත් infinit loop තමා... හැබැයි ලූප් වෙන්නේ useEffect එක තියෙන component එක නෙමෙයි.. අර PDF එක තියෙන div එක... ඒක නිකන් JS වල document onload event එක ඇතුලට redirect function එකක් දැම්ම වගේ...

    document retrieval part එකයි upload part එකයි useEffect එකෙන් එලියට ගලවල අරන් වෙනම ලියන්න ඕනේ..


    https://docs.apryse.com/documentation/web/guides/documentviewer/working-with-documents/
    https://docs.apryse.com/documentation/web/guides/basics/save/
     
    • Love
    Reactions: jennt

    jennt

    Well-known member
  • Sep 23, 2021
    2,958
    4,587
    113
    Abyss
    මේකේ මූ කරන්නේ pdftron lib එකෙන් PDF files edit කරල ඒක කොහෙටහරි upload කරන එකක්... මේකෙ documentLoaded event එක trigger වෙනවා මුලදි & මේකෙදි 👇
    Code:
    instance.UI.loadDocument(url, {extension: 'pdf'});

    එතකොට කොහොමත් infinit loop තමා... හැබැයි ලූප් වෙන්නේ useEffect එක තියෙන component එක නෙමෙයි.. අර PDF එක තියෙන div එක... ඒක නිකන් JS වල document onload event එක ඇතුලට redirect function එකක් දැම්ම වගේ...

    document retrieval part එකයි upload part එකයි useEffect එකෙන් එලියට ගලවල අරන් වෙනම ලියන්න ඕනේ..


    https://docs.apryse.com/documentation/web/guides/documentviewer/working-with-documents/
    https://docs.apryse.com/documentation/web/guides/basics/save/
    adee thanks aiya personally ooka research karala hoyala baluwata.
    ow custom editor ekak gahanna time tibbe naa. ekay sdk ekak use kalee.

    mata ee hati understanding ekak naa react gana. podi project 2k withara karala thiyenawa echcharay.
    mama godak study karanne data science + devOps.
    oyaa kiwwata passe tikak theruna.. thank you very much.

    samanyen man prashna ahala dana thread walata mehchcara engagement ekak enne naa..
    aththatama sathutuy mata wada godak seniors 3 denek meeka discuss karapu eka gana.

    ජෙමිනිගේ code එක වැඩ කරනවා දැකලා pressure වැඩි වෙලා
    Get well soon OP @jennt :(

    What The Reaction GIF by MOODMAN
    ow yakoo eeken passe mama hithagaththa pay karala gannawa kiyala magula.
    time eka ithuruy bn.
    eeye ookata 5hrs withara waste kalaa mama.


    I'm not talking about what is inside the useEffect in this particular case. I'm talking about the comment where you said empty dependency array will cause the effect to run in each render.

    a useEffect runs each render when there is no dependency array is provided, not when there is an empty dependency array.

    eka waradi nm react docs th waradi wenna one :rofl:
    https://react.dev/reference/react/useEffect#my-effect-runs-after-every-re-render

    PS: If you tried to say that useEffect runs after each render even if an empty array is provided because of the logic inside useEffect, no worries. I just wanted to correct that comment as in the way it was written, it was perceived as a generalized comment.
    thanks boss support ekata
    Mama innawa dapan Mata balagana Oni Mata waradunada kiyala. 😔
    thanks once again.

    :love:
     

    හෙළයෙක්

    Well-known member
  • Apr 26, 2014
    48,476
    98,427
    113
    මේකේ මූ කරන්නේ pdftron lib එකෙන් PDF files edit කරල ඒක කොහෙටහරි upload කරන එකක්... මේකෙ documentLoaded event එක trigger වෙනවා මුලදි & මේකෙදි 👇
    Code:
    instance.UI.loadDocument(url, {extension: 'pdf'});

    එතකොට කොහොමත් infinit loop තමා... හැබැයි ලූප් වෙන්නේ useEffect එක තියෙන component එක නෙමෙයි.. අර PDF එක තියෙන div එක... ඒක නිකන් JS වල document onload event එක ඇතුලට redirect function එකක් දැම්ම වගේ...

    document retrieval part එකයි upload part එකයි useEffect එකෙන් එලියට ගලවල අරන් වෙනම ලියන්න ඕනේ..


    https://docs.apryse.com/documentation/web/guides/documentviewer/working-with-documents/
    https://docs.apryse.com/documentation/web/guides/basics/save/
    ❤️❤️
     

    CorD SaC

    Well-known member
  • Feb 4, 2015
    15,724
    28,085
    113
    View attachment 225624

    JavaScript:
    useEffect(() => {
      // ... (WebViewer setup)
    
      const handleDocumentLoaded = async () => {
        // ... (Annotation handling, fetch, etc.)
        instance.Core.documentViewer.removeEventListener("documentLoaded", handleDocumentLoaded); // *** Remove the listener after execution***
      };
    
      documentViewer.addEventListener("documentLoaded", handleDocumentLoaded);
    
      // Keep cleanup in useEffect
      return () => {
        instance.Core.documentViewer.removeEventListener("documentLoaded", handleDocumentLoaded);
      };
    }, []);
    AI වලින් ලොකු impact එකක් එයි ඉස්සරහට තවත්. 😪