COMMUNITY

Video: Haxe and React using create-react-app workflow

Hi!

Just published a video introduction on how to integrate Haxe into a React create-react-app workflow. Includes using benmerckx’s watch library for auto-compiling the Haxe code, and using haxiomic’s dts2hx library for generating Haxe externs from third-party react libraries. Brief introductions on how to use functional components including hooks, as well as class-based components - all in a typesafe manner.

/ Jonas

12 Likes

Hey, nice! Definitely easier to get started with haxe + react this way :slight_smile:

Couple notes:

You might want to check React.createRef() for easier refs (and don’t ignore null values sent to your ref callback, it usually means your component unmounted, and you don’t want to keep an outdated reference).

Also, careful with “type safety” here; you don’t really have it in several places (hooks, context, and even props on the jsx side).

1 Like

It’s probably worth mentioning react-next for increased type safety in jsx (although I can’t fully comment on how far it goes these days).

As for hooks, I don’t see why they would not be typed. It is however true that the dependencies array is not statically checked, as it is with eslint/tslint in create-react-app’s setup. From my own experience, that’s not necessarily a down side though :smiley:

It’s probably worth mentioning react-next for increased type safety in jsx (although I can’t fully comment on how far it goes these days).

Yeah… but I don’t think it would work as well with dts2hx because of that =/

As for hooks, I don’t see why they would not be typed.

Yeah it depends how you write them, I double checked the video and it was fine I suppose