question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Components as classes and/or traits (ES6?)

See original GitHub issue

React is moving towards ES6 classes being the default form of existence for components. Voices in gitter all approve a similar transition in Scala.

Note: This will be in addition to ReactComponentB which won’t be removed.

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
japgollycommented, Sep 2, 2015

Backends are getting closer and closer to components as classes. (63aea4a241f23f9a142e53926a4f5f49d176c7a3, #78)

Idea: with a small change we could do:

class Backend($: BackendScope[Props, State]) { ... }

val Component = ReactComponentB[Backend] // With macro, P S B all known in one step
  .initialState(...)
  .build

Can also set the DOM node type too:

class Backend($: BackendScopeN[Props, State, html.Table]) {

Actually this is great. A type with no constraints at all (a class construtor param) can tell us all the static information about a component in one line with no repetition anywhere else. Can even have different ReactComponentB path depending on static info. This should makes it easy to solve #171 too.

0reactions
japgollycommented, Apr 26, 2017

As of 1.0, Scala component builder now creates ES6 classes (by default) for your Scala components. There’s also a unit test confirming that one can directly extend the ES6 facade and use it like any other component in scalajs-react.

Read more comments on GitHub >

github_iconTop Results From Across the Web

As a JS Developer, This Is What Keeps Me Up at Night - Toptal
What are ES6 classes? In ES6, the "class" keyword and associated features are a new approach to creating prototype constructors. They are not...
Read more >
ES6 Classes and Functional Components In Under 30 Minutes!
The list below contains some of the main features that each component has to offer: ES6 Class Components: Classes have more predefined methods ......
Read more >
Classes and Inheritance: JavaScript ES6 Feature Series (Pt 8)
Each object in JavaScript has a prototype object, which acts as a template that it inherits methods and properties from. That same prototype ......
Read more >
15. Classes - Exploring JS
Under the hood, ES6 classes are not something that is radically new: They mainly provide more convenient syntax to create old-school constructor functions....
Read more >
Building web components using ES6 classes - Polymer Project
First, I'll cover how to create the element using the vanilla web component JS APIs and then how to create the same element...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found