shoelace-style / react-wrapper Goto Github PK
View Code? Open in Web Editor NEWA lightweight utility that wraps custom elements ("web components") so they can be used like native React components.
License: MIT License
A lightweight utility that wraps custom elements ("web components") so they can be used like native React components.
License: MIT License
Some issues:
The first argument of method componentDidUpdate
is prevProps
=> we should pass this.props
to syncProps
instead:
react-wrapper/src/react-wrapper.jsx
Lines 16 to 18 in 2178d81
The second part of this condition should be removed
react-wrapper/src/react-wrapper.jsx
Line 27 in 2178d81
<SlSelect onsl-change={...}/>
will not work.
I do not understand why this.element
has to be of type RefObject<HTMLElement>
...
it could easily be of type HTMLElement | null
, couldn't it?
Just a remark:
Frankly, I personally do not really like this it.element.current.someMethod()
thingy (it does not feel very reactish). Wouldn't somethig like it.someMethod()
be much nicer? Would mean that the wrappers of all Shoelace component should be generated by a script (which they should be anyway, I guess) or the meta information about the method names should be available at runtime (static class field or @method
decorator or whatever). Using React.forwardRef
could also be an alternative, I guess. [Edit] I think React.forwardRef
is the way to go.
(no bug) Wrapper component should have a useful displayName
for debugging purposes.
When I import the react wrapper in a .tsx file, it throws the error 'Could not find a declaration file for module '@shoelace-style/react-wrapper'.' is there something I'm doing wrong or is there just no typescript support for this. I only ask because there are types for the individual components.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.