Provide easier way to use React and similar createElement functions
See original GitHub issueMainly creating this so we don’t have to hunt for it in the gitter chat later.
For React this interface function below will work. Should we provide this in pcb-stackup? Or maybe lower down in gerber-to-svg? The lack of unique key properties on some tags is also an issue.
var React = require('react')
var camelCase = require('lodash.camelcase')
function createElement(type, props, children) {
Object.keys(props).forEach(key => {
var newKey
if (key === 'xmlns:xlink') {
newKey = 'xmlnsXlink'
}
else if (key === 'xlink:href') {
newKey = 'xlinkHref'
}
else if (key === 'class') {
newKey = 'className'
}
else if (/-/.test(key)) {
newKey = camelCase(key)
}
if (newKey && newKey !== key) {
props[newKey] = props[key]
delete props[key]
}
})
return React.createElement(type, props, children)
}
Issue Analytics
- State:
- Created 7 years ago
- Comments:15 (7 by maintainers)
Top Results From Across the Web
React Without JSX
Using React without JSX is especially convenient when you don't want to set up ... The component can either be provided as a...
Read more >React Create Element - React Without JSX - KnowledgeHut
Let's Explore the Important React Component “React Create Element”. A Step-by-step Guide on How to Create React createElement Without JSX.
Read more >JSX Alternatives - Medium
JSX stands for JavaScript XML used in React to easily write HTML and ... and rendering that on the screen using the ReactDOM.render...
Read more >Functional Components with document.createElement, React ...
JSX looks almost exactly like HTML but it comes with the ability to use JavaScript to add even more power to your component....
Read more >React equivalent of document.createElement() - Stack Overflow
It would be handy if there's a function that can take the object that React.createElement creates and parse it into a DOM element......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
If you want to specify that a stackup should use external styles, it probably makes more sense to specify that via the stackup color option rather than the createElement function:
Each element can be individually set to a color or set to a falsey value to use an external style
Yeah, makes sense. Maybe we should actually remove
createElement
from pcb-stackup options (can still stay in core of course)?