Write Scala.js React apps just like you would in ES6
ReactElement
s within first-order types such as Map and List PR #285
setState
on a component with Props
set to some subtype of Function1
PR #295
useCallback
with a function that takes arguments PR #290
@react
classes if -Ywarn-value-discard
scalac option was used PR #296
target
property of event objects is no longer needed! Now all event handlers are statically typed based on the tag they are being placed on PR #243
ReactElement
, cannot be reused. Doing this will result in a runtime exception pointing out where the reuse occured PR #253
getDerivedStateFromProps
and getDerivedStateFromError
must now override the functions with a val
PR #248
React.forwardRef
function now takes a FunctionalComponentTakingRef
, which can be creating by creating a functional component that takes an additional ref parameter: FunctionalComponent((props, ref) => ...)
PR #227
ReactRef
type is no longer variant in its type parameters to increase type safety PR #227
displayName
when built in fullOptJS
mode, this results in a ~2.5% decrease in bundle size and matches behavior with JS where names are obfuscated in production builds PR #217
Option
writer now emits null
instead of js.undefined
for a value of None
PR #247
getDerivedStateFromProps
and getDerivedStateFromError
work correctly in fullOptJS
mode PR #248
Option
to None
in hot reloading mode PR #247
null
return values in derived state functions to not update the state PR #249
js.|
reader/writer implementations to work correctly in fullOptJS
mode PR #248
rowSpan
/colSpan
attribute (used to be rowspan
/colspan
) PR #224
This release includes a major rewrite of the tags API that eliminates the need to cast the target
value of event handlers and improves typesafety by more closely matching the official React API. As a result of these changes, event handlers defined in separate methods or code abstracting over tags may not initially compile with this new version.
Event handlers in previous versions of Slinky were functions from a DOM event type to Unit
. In React, events are normalized into SyntheticEvent
s that provide a common subset of the events generated in different browsers. In this version of Slinky, event handlers have been changed to all be functions from a synthetic event type (one of SyntheticEvent[TargetDOMType, UnderlyingDOMEventType]
, SyntheticMouseEvent[TargetDOMType]
, SyntheticTouchEvent[TargetDOMType]
, etc based on the event being listened to) to Unit
.
This means that explicit references to the DOM event type will no longer compile and will need to be replaced by an appropriate synthetic event type with a TargetDOMType
that matches the DOM type of the tag the listener is being placed on. This change ensures that the properties available on event objects at compile time match those generated by React.
In previous versions of Slinky, passing in attributes required the first attribute to be passed separately from the varargs parameter containing the rest of the attributes. In this version, the API for constructing tags has changed from apply
taking either (firstTag: AttrPair[...], otherTags: AttrPair[...]*)
or ReactElement*
to just a single method taking (mods: TagMod[...]*)
with conversions from AttrPair
and ReactElement
to this type.
So code that passed in generated attributes like:
div(firstAttr, restAttrs: _*)
will now need to be replaced by
div(allAttrs: _*)
Similarly, in components that previously took in AttrPair
and ReactElement
separately, this can now be simplified to just take TagMod
s.
getDerivedStateFromError
from React 16.6 PR #206
Suspense
component from React 16.6 PR #216
Props
or State
type PR #220
initialState()
is defined with the extra parentheses PR #218
Reader
/Writer
when private objects are involved PR #205
scala.Array
PR #187
defaultValue
attribute for specifying a default form value without overriding user inputs PR #186
Option
of an opaque type in their State
PR #198
ComponentWrapper
s not picking up manually defined Reader/Writers for the State
type PR #190
children
prop but no other props PR #189
@react
macro annotation with Component
/StatelessComponent
imported locally PR #188
value
attribute not being available on the select
and textarea
tags PR #177
fastOptJS
mode PR #162
@react
macro, and Macro Paradise is used instead. See the docs for updated installation instructions for adding the Macro Paradise compiler plugin PR #132
@react
components taking a children
prop now generate an apply
method with the children moved to a curried parameter to better match JSX PR #161
slinky-vr
module now points to React 360 PR #141
ReactComponentClass
now takes a type parameter of the Props
type to improve type safety with higher-order components. Existing uses can be safely replaced with ReactComponentClass[_]
PR #157
.toSlinky
and .toScalaJSReact
PR #151
shouldComponentUpdate
not being registered correctly on the component PR #135