Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import react.*
- import react.dom.*
- interface GithubComponentState : RState {
- var username: String
- var password: String
- var logged: Boolean
- }
- class GithubComponent : RComponent<RProps, GithubComponentState>() {
- init {
- state.logged = false
- }
- override fun RBuilder.render() {
- if (!state.logged) {
- fieldSet {
- label { +"Username: " }
- input {
- [...]
- }
- label { +"Password: " }
- input {
- [...]
- }
- button {
- +"Login"
- attrs.onClickFunction = {
- val gh = GitHub(User(state.username, state.password))
- gh.getUser()
- .then {
- setState {
- logged = true
- }
- }
- }
- }
- }
- } else {
- button {
- +"Logout"
- attrs.onClickFunction = {
- setState { logged = false }
- }
- }
- }
- }
- }
- fun RBuilder.github() = child(GithubComponent::class) {
- }
Add Comment
Please, Sign In to add comment