-
Notifications
You must be signed in to change notification settings - Fork 232
I figured out how to reuse the component class implementations from MDC directly in React #4
Comments
Update: I've managed to get Ripples, IconToggles, and Sliders implemented using this strategy and I'm happy to report it works splendidly. The Slider was a good one to work through because it is a relatively complex component.
Some other things to note about this implementation
I have no clue if this strategy interests anyone, but you get a ridiculous amount code reuse and consistency with MWC. |
I did some investigation and tests to see if there were any issues with your text field and button component. It all works as expected. I think your way of doing things is totally valid, and is easier to maintain as MDC Web outputs new features/code. I am interested in performance of MDC React vs RMWC. Although MDC Web is a very performant library, so I think if we find differences they would be negligible. |
That’s awesome to hear Matt! Would love to consolidate efforts in any way possible. I have a few non foundation components still but I plan on finishing up the transition with the next release. |
If this approach works without any significant performance overheads, then it'd enable fast feature parity with MDC Web and React MDC. With all due respect, the current list of ready components on the readme is not enough for anyone to start using this in a real world app. |
Does this implementation though prevent props from dictating component state? (React props driving what tab is selected, or if the dialog is open for example.) |
Nope. There is a function that gets run on reacts update cycle that also gets run when mdcs internal state changes. This ensures they sync bi-directionally. There might be an edge case hiding somewhere but I haven’t found it yet. |
@jamesmfriedman That's awesome, because I'm really liking Never mind: rmwc/rmwc#189 |
Literally ported them over this morning! They’re getting released later this week with MDC 36. With this last push, the foundation integration is totally complete. |
@mrchief totally agree. We do not have all the components we would like to have currently. I can say that as we build MDC Web components to the new spec, we are planning to build the matching MDC React components. |
We've decided to stick with the Foundation/Adapter approach. While this is more time consuming, we think using React's synthetic event system is inline with React development. We worry that using DOM events is anti-pattern in React, and will cause unintended consequences. |
Understood on wanting to take the long way around. Just a heads up for you though:
|
@lynnjepsen, I know I've been blowing you up on discord a bit, but I had to share this.
This is currently hacked together, but the fact that it works is crazy. I found a way to import the actual component class from MDC web and directly use it in React.
Check it out
rmwc/rmwc@17cdee6
What does this mean?
I don't have to reimplement a single foundation adapter! I can use all of the ones already written in MWC web with minimal tweaks. I need to work through this more to find the edge cases and do a real implementation, but I'm pretty stoked right now.
The text was updated successfully, but these errors were encountered: