Skip to content

Commit 9dbf1b0

Browse files
authored
Merge pull request #2 from Just-Feeshy/master
Usable for versions 4.0.0 and above
2 parents 16c3cc8 + 062b0b0 commit 9dbf1b0

File tree

3 files changed

+35
-10
lines changed

3 files changed

+35
-10
lines changed

src/react/router/BrowserRouter.hx

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package src.react.router;
2+
3+
/*
4+
* Avaliable for versions 4.0.0 and above
5+
*/
6+
7+
#if (jsImport)
8+
@:js.import('react-router-dom', 'BrowserRouter')
9+
#else
10+
@:jsRequire('react-router-dom', 'BrowserRouter')
11+
#end
12+
extern class BrowserRouter extends react.ReactComponent {}

src/react/router/HashRouter.hx

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package src.react.router;
2+
3+
/*
4+
* Avaliable for versions 4.0.0 and above
5+
*/
6+
7+
#if (jsImport)
8+
@:js.import('react-router-dom', 'HashRouter')
9+
#else
10+
@:jsRequire('react-router-dom', 'HashRouter')
11+
#end
12+
extern class HashRouter extends react.ReactComponent {}

src/react/router/Types.hx

+11-10
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,15 @@ typedef RouteProps = RoutePropsOf<Any, Any>;
1414
typedef RoutePropsOfParams<P> = RoutePropsOf<P, Any>;
1515
typedef RoutePropsOfQuery<Q> = RoutePropsOf<Any, Q>;
1616

17+
typedef Location<Q> = {
18+
pathname:Pathname,
19+
search:QueryString,
20+
query:Query<Q>,
21+
state:LocationState,
22+
action:Action,
23+
key:LocationKey,
24+
};
25+
1726
typedef RoutePropsOf<P, Q> = {
1827
route:Route<P, Q>,
1928
router:Router<P, Q>,
@@ -22,24 +31,16 @@ typedef RoutePropsOf<P, Q> = {
2231
}
2332

2433
private typedef Object = Any;
25-
@:enum
26-
private abstract Action(String) {
34+
#if haxe4 private enum #else @:enum private #end abstract Action(String) {
2735
var Push = 'PUSH';
2836
var Replace = 'REPLACE';
2937
var Pop = 'POP';
3038
}
39+
3140
private typedef Component = EitherType<Class<ReactComponent>, String>;
3241
private typedef EnterHook<P, Q> = RouterState<P, Q>->RedirectFunction<Q>->?Function->Any;
3342
private typedef Hash = String;
3443
private typedef LeaveHook<P, Q> = RouterState<P, Q>->Any;
35-
private typedef Location<Q> = {
36-
pathname:Pathname,
37-
search:QueryString,
38-
query:Query<Q>,
39-
state:LocationState,
40-
action:Action,
41-
key:LocationKey,
42-
};
4344
private typedef LocationDescriptorObject<Q> = {
4445
pathname:Pathname,
4546
search:QueryString,

0 commit comments

Comments
 (0)