{"id":1679,"date":"2024-08-02T11:06:22","date_gmt":"2024-08-02T09:06:22","guid":{"rendered":"https:\/\/blog.sutilweb.eu\/?page_id=1679"},"modified":"2024-08-02T11:06:23","modified_gmt":"2024-08-02T09:06:23","slug":"009-refactorizacion-de-la-app-enrutamiento-asincrono","status":"publish","type":"page","link":"https:\/\/sutilweb.eu\/index.php\/lenguajes\/javascript\/javascript-practico\/18-single-page-application-spa\/009-refactorizacion-de-la-app-enrutamiento-asincrono\/","title":{"rendered":"009. Refactorizaci\u00f3n de la App. Enrutamiento As\u00edncrono"},"content":{"rendered":"\n<p>En el cap\u00edtulo anterior hab\u00edamos creado el <strong>router<\/strong> de nuestra <strong>aplicaci\u00f3n<\/strong>, en el cual hay algunos detalles que vamos a solucionar, como es el de que se est\u00e1 duplicando la <strong>cabecera<\/strong>. En este cap\u00edtulo, vamos a hacer <strong>refactorizaci\u00f3n del c\u00f3digo<\/strong> que tenemos al momento en nuestra <strong>SPA<\/strong>.<\/p>\n\n\n\n<p>Vamos a ver tambi\u00e9n ciertas <strong>buenas pr\u00e1cticas<\/strong>, que en son importantes en un ambiente profesional, si no corregimos estos peque\u00f1os detalles, a posteriori puede traernos m\u00e1s problemas.<\/p>\n\n\n\n<!--more-->\n\n\n\n<p>El primer detalle que vamos a corregir es el de la <strong>cabecera<\/strong>, para que no se est\u00e9 duplicando. En este cap\u00edtulo modificaremos los archivos <em>App.js<\/em>, y al archivo <em>Posts.js<\/em> le renombramos a Main.js.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Archivos<\/h2>\n\n\n\n<p>Los archivos hasta este cap\u00edtulo son los siguientes:<\/p>\n\n\n\n<p>En el siguiente cap\u00edtulo trabajaremos con la vista que nos de el detalle de la publicaci\u00f3n que vayamos a visualizar.<\/p>\n\n\n\n<div class=\"wp-block-file alignleft\"><a id=\"wp-block-file--media-c39e4237-8dab-408b-9542-20a36c8ee288\" href=\"https:\/\/blog.sutilweb.eu\/wp-content\/uploads\/2024\/08\/spa-6.zip\">spa-6<\/a><a href=\"https:\/\/blog.sutilweb.eu\/wp-content\/uploads\/2024\/08\/spa-6.zip\" class=\"wp-block-file__button wp-element-button\" download aria-describedby=\"wp-block-file--media-c39e4237-8dab-408b-9542-20a36c8ee288\">Descarga<\/a><\/div>\n","protected":false},"excerpt":{"rendered":"<p>En el cap\u00edtulo anterior hab\u00edamos creado el router de nuestra aplicaci\u00f3n, en el cual hay algunos detalles que vamos a [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":1646,"menu_order":8,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_uag_custom_page_level_css":"","site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"class_list":["post-1679","page","type-page","status-publish","hentry"],"uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"1536x1536":false,"2048x2048":false},"uagb_author_info":{"display_name":"Sutil Web","author_link":"https:\/\/sutilweb.eu\/index.php\/author\/sutilweb\/"},"uagb_comment_info":0,"uagb_excerpt":"En el cap\u00edtulo anterior hab\u00edamos creado el router de nuestra aplicaci\u00f3n, en el cual hay algunos detalles que vamos a [&hellip;]","_links":{"self":[{"href":"https:\/\/sutilweb.eu\/index.php\/wp-json\/wp\/v2\/pages\/1679","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sutilweb.eu\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/sutilweb.eu\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/sutilweb.eu\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sutilweb.eu\/index.php\/wp-json\/wp\/v2\/comments?post=1679"}],"version-history":[{"count":3,"href":"https:\/\/sutilweb.eu\/index.php\/wp-json\/wp\/v2\/pages\/1679\/revisions"}],"predecessor-version":[{"id":1683,"href":"https:\/\/sutilweb.eu\/index.php\/wp-json\/wp\/v2\/pages\/1679\/revisions\/1683"}],"up":[{"embeddable":true,"href":"https:\/\/sutilweb.eu\/index.php\/wp-json\/wp\/v2\/pages\/1646"}],"wp:attachment":[{"href":"https:\/\/sutilweb.eu\/index.php\/wp-json\/wp\/v2\/media?parent=1679"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}