-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
55a8591
commit 5914ecc
Showing
6 changed files
with
45 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,28 @@ | ||
let home = () => Routes.(nil); // '/' | ||
let hello = () => Routes.(s("hello") /? nil); // /hello | ||
|
||
let homeRoute = Routes.(home() @--> (() => print_endline("in home page"))); | ||
let helloRoute = Routes.(hello() @--> (() => print_endline("in hello view"))); | ||
|
||
let routes = Routes.one_of([homeRoute, helloRoute]); | ||
|
||
module Main = { | ||
[@react.component] | ||
let make = () => { | ||
let target = | ||
ReasonReactRouter.useUrl().path | ||
|> String.concat("/"); | ||
switch (Routes.match'(routes, ~target)) { | ||
| Routes.FullMatch(e) => e() | ||
| Routes.MatchWithTrailingSlash(e) => e() | ||
| Routes.NoMatch => () | ||
}; | ||
<Reason_india_website_js.App />; | ||
} | ||
}; | ||
|
||
switch (ReactDOM.querySelector("#root")) { | ||
| Some(el) => ignore @@ ReactDOM.Client.hydrateRoot(el, <Reason_india_website_js.App />) | ||
| Some(el) => | ||
ReactDOM.Client.createRoot(el)->ReactDOM.Client.render(<Main />) | ||
| None => () | ||
}; |
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,7 +1,7 @@ | ||
(melange.emit | ||
(alias client) | ||
(target app) | ||
(libraries melange reason_india_website_js reason-react) | ||
(libraries routes melange reason_india_website_js reason-react) | ||
(preprocess | ||
(pps reason-react-ppx melange.ppx)) | ||
(module_systems commonjs)) |
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
[@alert "-all--all+browser_only"]; | ||
let%browser_only handleLinkAnchorOnClick = (href, e) => { | ||
React.Event.Mouse.preventDefault(e); | ||
ReasonReactRouter.push(href); | ||
}; | ||
|
||
|
||
[@react.component] | ||
let make = (~href, ~children) => { | ||
<a onClick={handleLinkAnchorOnClick(href)} href> {children} </a>; | ||
}; |
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