1

In React I can build up an array of abritrary component instances in javascript in order to componse them - this is very useful for generating dynamic forms (simplified example with made up component names):

render() {
   // formEls would dynamically generated, static for example only
   const formEls = [<Decimal />, <Boolean />, <Checkbox />
   return <form>{formEls}</form>

How can I do similar in LWC?

1

Aura framework faced so many internal problems because of dynamic creation of components. Salesforce confirmed that true dynamic creation of components will never be available in LWC. Reasons and alternatives are given in Use template string in render() instead of an imported template html file

1
  • Thanks for that information, it clears things up for me. Quite unfortunate that they have gone down that path - I guess we will continue on with our suite of react LDS components. – user1781563 Jul 23 '19 at 13:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.