Convert Svg() to JSX#3573
Conversation
Codecov Report
@@ Coverage Diff @@
## master #3573 +/- ##
==========================================
- Coverage 52.59% 52.57% -0.03%
==========================================
Files 119 119
Lines 4649 4649
Branches 958 958
==========================================
- Hits 2445 2444 -1
- Misses 2204 2205 +1
Continue to review full report at Codecov.
|
|
Hi, Maybe it is worth, while you are at it, to try an update |
| } | ||
| props = Object.assign({}, props, { className, src: svg[name] }); | ||
| return React.createElement(InlineSVG, props); | ||
| return <InlineSVG {...props} />; |
There was a problem hiding this comment.
So this is an idea. But you'd need to touch more of the codebase. How about converting this component from:
module.exports = function(name, props) {
// eslint-disable-line
if (!svg[name]) {
throw new Error("Unknown SVG: " + name);
}
let className = name;
if (props && props.className) {
className = `${name} ${props.className}`;
}
if (name === "subSettings") {
className = "";
}
props = Object.assign({}, props, { className, src: svg[name] });
return <InlineSVG {...props} />;
};to
export default function Svg({ name, ...props }) {
// eslint-disable-line
if (!svg[name]) {
throw new Error("Unknown SVG: " + name);
}
let className = name;
if (props && props.className) {
className = `${name} ${props.className}`;
}
if (name === "subSettings") {
className = "";
}
props = { ...props, { className, src: svg[name] } };
return <InlineSVG {...{ ...props, className, src: svg[name] }} />;
};We would need to modify the usage of Svg but then we could use it like a component as well and convert the usages like so
// from this
Svg("some-name", { foo: bar });
// to this
<Svg name="some-name", foo={bar} />|
@zaggy I would leave it for now as it's a major version bump. |
|
@wldcordeiro I was thinking the same but I didn't want to touch every file that used it yet; easier if we JSX all the components and then make this change |
@darkwing agreed. I'll amend the main issue with that as an item. |
Ticking another one off.