Redirecting Pages
Learn how we can redirect pages with the spaRedirect() function.
About the application
In this application, we’ll look at final modifications in some of the existing Python modules. We’ll learn how the application uses the customized Link
component wrapped inside the Typography
component, which is further wrapped inside the FlexboxCenter
component. Next, we’ll be taking a look at modifications, which include both addition and removal of some functionalities in modules after the spaRedirect()
function is incorporated in them.
This is what the application looks like:
Note: To log in, use the username
admin
and password123
.
Copyright (c) 2020 John Sheehan Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
Modifications in the landingPageView
module
The requirement is to update all of the application views to utilize the new SPA redirect functionality. Our application will use the spaRedirect()
function to facilitate a view change and factor in utilizing the URL parameters to initialize the state when view components are loaded. Let’s look at the changes in the landingPageView.py
module, located inside the bookapp/client/src/views/landingPage/
folder.
At lines 15 and 16 for the LandingPage
component, instead of using the setBooksShow()
function that was previously passed in as a prop to change views, we now have the params
and pathname
props and the spaRedirect()
function to control the view at line 37.
One of the keys that may be included in the params
dictionary is “login”, which will trigger the modal Login
view to be visible when set to ...