-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Add Redirect Comp. * Fix router behaviour. * Fix output. * Fix pr-flow. * Remove Redirect. * Readd 77b46bf. * Router Context, History and Location. * Finish Porting. * Add Switch, Fix example. * Add state. * Fix pr-flow. * Fix pr-flow. * Fix unstable feature for 1.49. * Add documentation. * Error Types & Simplify Implementation. * Add some tests. * Update documentation. * Fix route outside of a Switch.
- Loading branch information
Showing
22 changed files
with
1,444 additions
and
389 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
//! Components to interface with [Router][crate::Router]. | ||
mod link; | ||
mod redirect; | ||
pub use link::*; | ||
pub use redirect::*; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
use wasm_bindgen::UnwrapThrowExt; | ||
use yew::prelude::*; | ||
|
||
use crate::history::History; | ||
use crate::hooks::use_history; | ||
use crate::Routable; | ||
|
||
/// Props for [`Redirect`] | ||
#[derive(Properties, Clone, PartialEq)] | ||
pub struct RedirectProps<R: Routable> { | ||
/// Route that will be pushed when the component is rendered. | ||
pub to: R, | ||
} | ||
|
||
/// A component that will redirect to specified route when rendered. | ||
#[function_component(Redirect)] | ||
pub fn redirect<R>(props: &RedirectProps<R>) -> Html | ||
where | ||
R: Routable + 'static, | ||
{ | ||
let history = use_history().expect_throw("failed to read history."); | ||
|
||
let target_route = props.to.clone(); | ||
use_effect(move || { | ||
history.push(target_route.clone()); | ||
|
||
|| {} | ||
}); | ||
|
||
Html::default() | ||
} |
Oops, something went wrong.