Creating a Custom Router
Custom routers can be used to define custom routing logic for your application. This is useful when you need to implement a custom routing algorithm or when you need to integrate with an existing URL routing system.
Step 1: Creating a custom resolver¶
You may want to create a custom resolver to allow ReactPy to utilize an existing routing syntax.
To start off, you will need to create a subclass of ReactPyResolver
. Within this subclass, you have two attributes which you can modify to support your custom routing syntax:
param_pattern
: A regular expression pattern that matches the parameters in your URL. This pattern must contain the regex named groupsname
andtype
.converters
: A dictionary that maps atype
to it's respectiveregex
pattern and a converterfunc
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
|
Step 2: Creating a custom router¶
Then, you can use this resolver to create your custom router...
1 2 3 4 5 6 |
|
Last update: January 12, 2025
Authors: