Last active
April 20, 2025 02:20
-
-
Save barnabyc/f2e7ab5281f0df05b6b8 to your computer and use it in GitHub Desktop.
Aviator/React example
This file contains hidden or 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
import Aviator from 'vendor/aviator'; | |
import ServerRouteTarget from 'route_targets/server_route_target'; | |
let Routes = { | |
/** | |
Call this method `Routes.dispatch` to start routing. | |
@method dispatch | |
@param {Object} targets | |
@example { 'nameOfMyRouteTarget': instanceOfMyRouteTarget } | |
**/ | |
dispatch: function (targets) { | |
Aviator.setRoutes({ | |
'/servers': { | |
target: ServerRouteTarget, | |
'/:id': { | |
'/': 'show' | |
} | |
}); | |
Aviator.dispatch(); | |
} | |
}; | |
export default Routes; | |
This file contains hidden or 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
/** @jsx React.DOM */ | |
import React from 'vendor/react'; | |
import Server from 'components/server_component'; | |
/** | |
@module ServerRouteTarget | |
**/ | |
let ServerRouteTarget = { | |
getPageNode: function () { document.getElementById('page') }, | |
/** | |
@method show | |
@param {Aviator.Request} | |
**/ | |
show: function (request) { | |
React.renderComponent( | |
<Server />, | |
ServerRouteTarget.getPageNode() | |
); | |
} | |
}; | |
export default ServerRouteTarget; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Console