-
Notifications
You must be signed in to change notification settings - Fork 38
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
Use haxe-react when react installed as a package #8
Comments
I've added manually this:
to my haxe js output before it gets browserifyied and it works... What would be the clean way to do this in haxe-react ? |
Yes currently haxe-react depends on including React as a JS, not through Making the current externs
Of course you then have to use Browserify or Webpack to get it to work. I'm working on an example which will introduce this change, but you can quickly do the change yourself for now - if you manage to use some addons that would be helpful to share it. |
Thanks for your answer. I will definitively share my work on using haxe-react with react addons and libs (material-ui for example). It will be a set of haxe externs basically... |
@zabojad did you try to use the ReactWithAddOns bundle? https://facebook.github.io/react/blog/2015/10/28/react-v0.14.1.html We definitiely need at some point to support |
@elsassph yes, I've tried it from there https://facebook.github.io/react/downloads.html But what I do now is that I define externs with the @:jsRequire meta tag. I'm not only using the "official" react addons but also other react components like the material-ui ones. Externs + @:jsRequire + browserify works perfectly. I'll come back to you later with a complete set of externs for what I've used to get your two cents on one or two things... |
Just pushed the |
Hi @elsassph !
Toggle is a genuine react component. However, how could you write its extern so that when I use it with the I would need something like:
But of course that won't work... What would be the right way to define those externs? |
I wonder if this would work? |
@dpeek it compiles, but doesn't do any type checking at compile time... |
Ah, I see what you mean. It will compile time check if you subclass it at least. Infact I was just talking to @elsassph about compile time checking of props in JSX – I think it's possible... |
@dpeek mmm, that sound like a good idea. In that case, it would go through the jsx macro context and indeed be type checked at compilation... It creates quite some extra work at creating "externs" though... It might be "ignorable" but I've crossed one case where I couldn't subclass a comp because it is designed "final". The Tab cmp from material-ui for example cannot be subclassed because its natural parent component (Tabs) will detect it at runtime and won't allow it... |
Hi there ! |
The initial issue question was covered so I'm closing the issue. |
I'm struggling with using React addons components with haxe-react.
The problem is that most react addons are distributed as npm packages. They usually contains
var React = require('react')
statements which makes browserify including react in the output file (I did not find a way to exclude it from the output file).On the other side, haxe-react seems to work only when React is used not as an npm package, but rather included via a script tag in the html page header.
The problem with this is that there can be only one React included at a time. If not, we get the following error at runtime:
If then I remove the script tags that import react and react-dom, I get of course this, as my compile haxe-react code does not find React:
As it seems that react components are distributed as npm packages only, the way would be to make haxe-react work with an npm version of React. How can we do that ?
The text was updated successfully, but these errors were encountered: