-
-
Save ultimateprogramer/2aed676db2e988ec8a8035126930f0e1 to your computer and use it in GitHub Desktop.
Simple Aviator/React example. Read more about Aviator here: https://github.com/swipely/aviator
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
/** @jsx React.DOM */ | |
var AppRouteTarget = { | |
setupLayout: function () { | |
React.renderComponent({ | |
<App className='page-content'>, | |
document.querySelector('body') | |
}); | |
} | |
}; |
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
// define routes | |
Aviator.setRoutes({ | |
target: AppRouteTarget, | |
// setupLayout is run for every route in the route tree. | |
'/*': 'setupLayout' | |
'/users': { | |
target: UsersRouteTarget, | |
'/': 'list' | |
'/:id': 'show' | |
} | |
}); | |
// Start routing | |
Aviator.dispatch(); |
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
/** @jsx React.DOM */ | |
var UsersRouteTarget = { | |
list: function () { | |
// placeholder - use favorite ajax lib here | |
var users = []; | |
React.renderComponent({ | |
<UserList users={users}/>, | |
document.querySelector('.page-content') | |
}); | |
}, | |
show: function (request) { | |
// placeholder - use favorite ajax lib here | |
var user = { id: request.params.id }; | |
React.renderComponent({ | |
<User user={user}/>, | |
document.querySelector('.page-content') | |
}); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment