Filtering through url frontend react









up vote
0
down vote

favorite












I notice that when I update filter, it also update url and vice versa



For example, youtube: https://www.youtube.com/



When I search 'stackoverflow' the url changes to:
https://www.youtube.com/results?search_query=stack+overflow



And when I filter HD video, the url changes to:
https://www.youtube.com/results?sp=EgQQASAB&search_query=stack+overflow



See that ?sp=EgQQASAB, why do they try to encode this part, at least it is not human readable?



When I click back button. It goes to
https://www.youtube.com/results?search_query=stack+overflow
https://www.youtube.com/



How to append this to url: ?search_query=stack+overflow (why not encode this part too)



I have seen this on many websites and I know that this is best practice. So my question is:



  • What exactly the name of this best practice/technique? I hardly find any articles or tutorials?


  • why do we need to do this


  • Are there any good articles that I can learn? I have searched these articles but it always get me to some backend articles (like best way to handle url backend) and this one is frontend


  • Do you have any diagram to visualize this best practice? (forexample:
    When we fetch data, first capture query from url and append it to the request to send to server. When we update filter, first update url and then capture query from url and send request to server? How about when we click back button? I notice that when we click back it update the data, url and also the state of filter component like search bar.... I don't know, just ask about the flow of this). So we have to manage data, url and state of component at the same time, we try to somehow sync this?


  • How can I apply this using React (any good demo on github and articles)










share|improve this question



























    up vote
    0
    down vote

    favorite












    I notice that when I update filter, it also update url and vice versa



    For example, youtube: https://www.youtube.com/



    When I search 'stackoverflow' the url changes to:
    https://www.youtube.com/results?search_query=stack+overflow



    And when I filter HD video, the url changes to:
    https://www.youtube.com/results?sp=EgQQASAB&search_query=stack+overflow



    See that ?sp=EgQQASAB, why do they try to encode this part, at least it is not human readable?



    When I click back button. It goes to
    https://www.youtube.com/results?search_query=stack+overflow
    https://www.youtube.com/



    How to append this to url: ?search_query=stack+overflow (why not encode this part too)



    I have seen this on many websites and I know that this is best practice. So my question is:



    • What exactly the name of this best practice/technique? I hardly find any articles or tutorials?


    • why do we need to do this


    • Are there any good articles that I can learn? I have searched these articles but it always get me to some backend articles (like best way to handle url backend) and this one is frontend


    • Do you have any diagram to visualize this best practice? (forexample:
      When we fetch data, first capture query from url and append it to the request to send to server. When we update filter, first update url and then capture query from url and send request to server? How about when we click back button? I notice that when we click back it update the data, url and also the state of filter component like search bar.... I don't know, just ask about the flow of this). So we have to manage data, url and state of component at the same time, we try to somehow sync this?


    • How can I apply this using React (any good demo on github and articles)










    share|improve this question

























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I notice that when I update filter, it also update url and vice versa



      For example, youtube: https://www.youtube.com/



      When I search 'stackoverflow' the url changes to:
      https://www.youtube.com/results?search_query=stack+overflow



      And when I filter HD video, the url changes to:
      https://www.youtube.com/results?sp=EgQQASAB&search_query=stack+overflow



      See that ?sp=EgQQASAB, why do they try to encode this part, at least it is not human readable?



      When I click back button. It goes to
      https://www.youtube.com/results?search_query=stack+overflow
      https://www.youtube.com/



      How to append this to url: ?search_query=stack+overflow (why not encode this part too)



      I have seen this on many websites and I know that this is best practice. So my question is:



      • What exactly the name of this best practice/technique? I hardly find any articles or tutorials?


      • why do we need to do this


      • Are there any good articles that I can learn? I have searched these articles but it always get me to some backend articles (like best way to handle url backend) and this one is frontend


      • Do you have any diagram to visualize this best practice? (forexample:
        When we fetch data, first capture query from url and append it to the request to send to server. When we update filter, first update url and then capture query from url and send request to server? How about when we click back button? I notice that when we click back it update the data, url and also the state of filter component like search bar.... I don't know, just ask about the flow of this). So we have to manage data, url and state of component at the same time, we try to somehow sync this?


      • How can I apply this using React (any good demo on github and articles)










      share|improve this question















      I notice that when I update filter, it also update url and vice versa



      For example, youtube: https://www.youtube.com/



      When I search 'stackoverflow' the url changes to:
      https://www.youtube.com/results?search_query=stack+overflow



      And when I filter HD video, the url changes to:
      https://www.youtube.com/results?sp=EgQQASAB&search_query=stack+overflow



      See that ?sp=EgQQASAB, why do they try to encode this part, at least it is not human readable?



      When I click back button. It goes to
      https://www.youtube.com/results?search_query=stack+overflow
      https://www.youtube.com/



      How to append this to url: ?search_query=stack+overflow (why not encode this part too)



      I have seen this on many websites and I know that this is best practice. So my question is:



      • What exactly the name of this best practice/technique? I hardly find any articles or tutorials?


      • why do we need to do this


      • Are there any good articles that I can learn? I have searched these articles but it always get me to some backend articles (like best way to handle url backend) and this one is frontend


      • Do you have any diagram to visualize this best practice? (forexample:
        When we fetch data, first capture query from url and append it to the request to send to server. When we update filter, first update url and then capture query from url and send request to server? How about when we click back button? I notice that when we click back it update the data, url and also the state of filter component like search bar.... I don't know, just ask about the flow of this). So we have to manage data, url and state of component at the same time, we try to somehow sync this?


      • How can I apply this using React (any good demo on github and articles)







      reactjs web frontend






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 10 at 21:17

























      asked Nov 10 at 21:10









      coinhndp

      18510




      18510



























          active

          oldest

          votes











          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













           

          draft saved


          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53243432%2ffiltering-through-url-frontend-react%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown






























          active

          oldest

          votes













          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes















           

          draft saved


          draft discarded















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53243432%2ffiltering-through-url-frontend-react%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          這個網誌中的熱門文章

          Barbados

          How to read a connectionString WITH PROVIDER in .NET Core?

          Node.js Script on GitHub Pages or Amazon S3