Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create ReactClassBuilder #19

Closed
shogowada opened this issue Mar 30, 2017 · 0 comments
Closed

Create ReactClassBuilder #19

shogowada opened this issue Mar 30, 2017 · 0 comments

Comments

@shogowada
Copy link
Owner

shogowada commented Mar 30, 2017

Many developers are more comfortable writing functions than classes. Create ReactClassBuilder that lets you create ReactClass purely by composing functions.

Draft (incomplete and highly likely to change, but just to demonstrate the idea):

case class ReactClassContext[WrappedProps, State](
  native: js.Dynamic,
  props: Props[WrappedProps],
  state: State
) {
  def setState(state: State): Unit = // ...
}

val reactClass: ReactClass =
    ReactClassBuilder[Props, State]()
        .shouldComponentUpdate((context: ReactClassContext[WrappedProps, State], nextContext: ReactClassContext[WrappedProps, State]) => Boolean)
        .render((context: ReactClassContext[WrappedProps, State]) => ReactElement)
        .build
@shogowada shogowada changed the title Create ReactClassSpecBuilder Create ReactClassBuilder Apr 15, 2017
@shogowada shogowada mentioned this issue Apr 20, 2017
1 task
shogowada added a commit that referenced this issue Apr 20, 2017
* Compile

* Fix not setting default initial state

* Refactor

* Refactor

* Rename Context to Self

* Rename Context to Self

* Update README.md

* Update README.md

* Update README.md

* Update ContainerComponents.scala

* Refactor

* Try Firefox 52.0

* v0.10.0

Close #19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant