alexlafroscia / ember-react-components

Render React components in Ember
https://alexlafroscia.github.io/ember-react-components
MIT License
51 stars 16 forks source link

Merge with AltSchool Repo #10

Open lifeart opened 6 years ago

lifeart commented 6 years ago

Is any way to get only one solution?

lifeart commented 6 years ago

https://github.com/AltSchool/ember-cli-react/issues/22

alexlafroscia commented 6 years ago

What exactly are you looking for?

I built this mostly as an experiment, borrowing a bit from the code in the AltSchool repo. If they're interested in updating their addon to support the decorator that I created, I would be happy to deprecate my repo and offer the code to them as long as I can maintain the commit bit on my code.

I'm not sure there's a whole lot to merge, though, as the approaches are fairly different. There are tradeoffs on both sides.

lifeart commented 6 years ago

@alexlafroscia, thank you for response! I'm just wondering why both repos looks alive, but have different approaches. I think it will be nice to have single 'react-components-in-ember' implementation to get it more featurable and stable. Can you please explain main differences beetween this repos? Is any way to create single repo from both repos?

alexlafroscia commented 6 years ago

Are there features or stability that you're finding lacking in either addon?

Both addons wrap a React component in an Ember one, the difference is just how.

My decorator approach takes a React component and wraps it in an Ember component within the component file, so that nothing knows that it's not just an Ember component.

The AltSchool approach leverages the resolver to achieve the same thing; when looking up a component, if the things returned isn't actually a component, wrap it in an Ember shim before rendering it.

There are some benefits on both sides

AltSchool approach:

My approach:

Both addons:

I don't know if there is really a huge benefit from one over the other but I personally like my approach better 🤷‍♂️ Unfortunately for me, they already have the ember-cli-react NPM package name so I have to pick something else if I want to publish to NPM.

wmertens commented 5 years ago

Does either approach have a solution for the having-dependencies-available-as-umd problem?

I'm thinking that it would be better if the react components do their own script loading, not via ember

alexlafroscia commented 5 years ago

Can you explain what you mean by that, @wmertens?

wmertens commented 5 years ago

Well, there's a bunch of tooling around React, like react-hot-loader, which requires e.g. webpack to run the build of the React components. Since Ember takes over the build process, that can't be used.

If the React app is just a script that you load and then get a global from, then Ember doesn't need to do any loading of React or the dependencies. So I'm now exploring how to integrate a fully self-contained React renderer.

lifeart commented 5 years ago

@wmertens https://github.com/lifeart/ember-ast-hot-load should hotreload any components

wmertens commented 5 years ago

@lifeart Hmm looks like that won't work with react-hot-loader though.

lifeart commented 5 years ago

@wmertens why you need react-hot-loader if ember-ast-hot-loader can hotreload react components inside ember?

wmertens commented 5 years ago

@lifeart react-hot-loader does extra work to maintain the internal state of the elements, so that forms, buttons, dropdowns etc don't get reset after reload. It uses the webpack module.hot API to do this.

I got things working like this:

end result: ember dev also starts a webpack compiler that serves the react components and handles hot reloading.

still to figure out: