Skip to content

Latest commit

 

History

History
79 lines (43 loc) · 2.43 KB

faq.md

File metadata and controls

79 lines (43 loc) · 2.43 KB

Frequently Asked Questions

"Please use 'new' operator" error

TypeError: Failed to construct 'HTMLElement': Please use the 'new' operator, this DOM object constructor cannot be called as a function.

Possible solutions:

  • Try adding custom-elements-es5-adapter

  • Disable class transforms in Babel

The x- prefix

Q: Why are all your example tags prefixed with x-?

The x- prefix is not required. However, it's featured in a lot of Remount's examples for a few reasons:

  • All custom elements require a - in the name (source). Prefixing with x- makes it easy to use single-word elements, which most the examples feature (eg, x-tooltip).

  • One early proposal for custom elements was from Mozilla, in the form of x-tag. It required custom elements to be prefixed with x-. While the x-tag proposal is dead now, I think the convention has merit.

Comparison to prior art

Q: Why should I use Remount, and not $another_library?

See Comparison.

Remount in React

Q: Can I use Remount to put React components in React components?

Yes, but it'd be better if you just use React. You're sure to have better performance that way.

create-react-app

Q: How do I use it with create-react-app?

Remount works in create-react-app just fine! Try adding this to your src/index.js:

import { define } from 'remount'

define({
  'x-hello': () => {
    return <div>Hello from Remount :)</div>
  }
})

Codesandbox

Q: How do I use Remount on Codesandbox?

The default Codesandbox React template is based on create-react-app. See the answer above.

Jsfiddle

Q: How do I use Remount on Jsfiddle?

Fork this template.

Preact

Q: Will it work with Preact?

Yes! Try it with the preact-compat package. Make sure you set up your Webpack configuration as the preact-compat docs suggests.

Happy face

Q: Who's that guy in the README cover photo?

I stole @rem's face from uifaces.com.

Issue tracker

Q: I have a question not in this FAQ.

Search the issue tracker to see if anyone else reported your issue. Feel free to open a new issue if not.