Slinky 0.6.0: The One With Hooks

React Hooks, type-safe tags, and more!

Slinky is a framework for writing React and React Native applications in Scala with an API that mirrors JavaScript and a fantastic developer experience. Slinky 0.6.0 is one of the biggest releases yet, featuring support for React Hooks and improved type-safety when writing components with a brand new tag API! In addition, this release comes with some new additions to the Slinky community, such as the new https://slinky.dev homepage!

But first… Hooks!!!

a brand new way to write React components awaits!

React Hooks are the largest change to how React apps are written since the creation of React itself, offering a fundamentally different approach to writing components that results in cleaner and smaller code. If you’re just starting out with Hooks, I recommend taking a look at some of Dan Abramov’s posts, which explain the principles behind Hooks more in depth.

With Slinky 0.6.0, the entire Hooks API is now available along with functional component support so you can write applications using React Hooks!

a simple component with Hooks in Slinky looks almost the same as the component in React!

Following the goal of Slinky — to make it possible to write React applications in Scala just like you would with ES6 — the Hooks API in Slinky is almost identical to that when using vanilla React. This means that getting started with Hooks is super easy. All the information from the official React docs directly translates over to Slinky code, with nothing additional to learn on top of that (which means less Slinky-specific docs for me to write!). In addition, JavaScript examples from around the web (like useHooks) work perfectly when converted to Scala, so you always have access to the full power of Hooks.

Type-Safe(er) Tags

As a library for Scala, one of the primary goals of Slinky is to provide as much type safety as possible without getting in the way of the developer. Slinky 0.6.0 takes a stride towards this goal with a brand new approach to the tag API that resolves one of the oldest issues on the Slinky repository!

the new tags API can clean up event handlers a lot!

In previous versions of Slinky, the target property of events would be untyped, so you would have to use asInstanceOf to manually cast it to the element type you are expecting. With Slinky 0.6.0, the target type is automatically calculated based on the tag the event is being placed on, eliminating unnecessary casts and improving overall type safety!

New Docs Domain!

The Slinky docs have moved to a new domain: https://slinky.dev! This isn’t exactly a new feature, but it’s still pretty awesome! 🎉

Get Started Today!

Slinky 0.6.0 is out on Maven Central today! Check out the CHANGELOG to see changes you might have to make if upgrading from an older version of Slinky.

If you’re getting started with Slinky for the first time, you can use Create React (Native/VR) Scala App to get started with a full application with build tools already configured and ready to go!

sbt new shadaj/create-react-scala-app.g8 # For React on the web

sbt new shadaj/create-react-native-scala-app.g8 # For React Native

sbt new shadaj/create-react-vr-scala-app.g8 # For React VR/360

Make sure to check out the Slinky documentation and GitHub repo too!

And be sure to join the Gitter community to stay up to date on the latest developments in Slinky and chat with other Slinky devs!