3 ms·
const MyComponent: React.FC<{style?:React.CSSProperties}> = (props) => <div style={{margin: 16, ...props.style}}>{props.children}</div> I don't see any issue;
by TomMarius 7y ago
const MyComponent: React.FC<{style?:React.CSSProperties}> = (props) => <div style={{margin: 16, ...props.style}}>{props.children}</div>
I don't see any issue; additionally, it's well typed and you have fine control over it!
- spankalee 7y agoThat's not stylable from CSS though, so you have to pass JS props and can't use selectors. It also duplicates styling strings across all similar style attributes which is not good for memory or perf.
- TomMarius 7y agoNoone using React cares about styling from CSS though. It doesn't have to duplicate much, you can use e.g. typestyle or React Native's Stylesheet