question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Provide easier way to use React and similar createElement functions

See original GitHub issue

Mainly 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:closed
  • Created 7 years ago
  • Comments:15 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
mcouscommented, Dec 26, 2016

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:

const stackup = pcbStackup(layers, {
  id: 'some-id',
  colors: {
    fr4: false,
    cu: false,
    cf: false,
    sm: false,
    ss: false,
    sp: false,
    out: false
  }
})

Each element can be individually set to a color or set to a falsey value to use an external style

0reactions
kasbahcommented, Feb 25, 2019

Yeah, makes sense. Maybe we should actually remove createElement from pcb-stackup options (can still stay in core of course)?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found