This repository was archived by the owner on Jan 14, 2025. It is now read-only.
This repository was archived by the owner on Jan 14, 2025. It is now read-only.
I figured out how to reuse the component class implementations from MDC directly in React #4
Closed
Description
@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.
- I import the class
- Pass it to an HOC
- I create a new React Component
- I copy the MWC component class descriptors over to the new class
- I handle the DOM refs in a way that reflects the way the MDC component expects them
- The only things I need to specify at this point are things that work a bit different in react like setting classes and a syncWithProps function which can handle the react render cycle.
- It is currently hacky as hell, but I thought about this an hour ago and I'm still in shock it actually works.
Check it out
- Don't mind all the code in the commit just look at base/MDCFoundation and IconToggle/index.
- npm run storybook, navigate to IconToggle
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.
Metadata
Metadata
Assignees
Labels
No labels