0

Currently, I'm targeting the aura:attribute by its name but the problem I'm having is when I'm setting the body of v.reactApp in my controller is setting it for all of the components that are already rendered referenced by that name overriding the body they had. So for a workaround, I want to know if it's possible to make the name dynamic (so it's unique) and pass it to the controller so when I do cmp.set("v.reactApp", [methods]) the name v.reactApp can be dynamically created or add to it a unique identifier something like: (name={"reactApp + Math.random()"})and for the controller to have access to it so when we do cmp.set it targets the correct attribute.

**This is the aura attribute **

   <aura:attribute name="reactApp" type="Aura.Component[]" access="global"/>

This is the controller

init: function(cmp) {
    let aId = Math.random();

    $A.createComponent(
      "div",
      {
        id: aId
      },
      function(methods) {
        cmp.set("v.reactApp", [methods]);
      }
    );
  }

More context: This is a component that every time an agent opens a case tab on salesforce this code gets triggered and creates an LWC aura component per each tab with its unique state. Before Salesforce upgraded to API 48.0 the code was working but now with this new update, it seems to not know to which element is being pushed even when created dynamically.

  • I dont seem to understand setting the body of v.reactApp in my controller is setting it for all of the components that are already rendered referenced by that name overriding the body they had , are all other child components using the same attribute v.reactApp – Pranay Jaiswal Feb 16 at 19:42
  • Perhaps you just need another attribute on your component to store the unique id? Consider using Global Ids once the child is created to differentiate between the other components – Brian Miller Feb 16 at 20:11
  • @PranayJaiswal This is basically a LWC aura component that every time a salesforce agaent opens a new case tab this component gets set into the body with its unique state in the body and with a div with an unique ID. Once salesforce upgraded to API 48.0 now when I create this aura component it overrides the state of the body of all the other that were already rendered. – Gigi Feb 16 at 20:41
  • @BrianMiller I tried the adding the unique id except I'm struggling on the part where the controller is able to find this component by its GlobalID and push to only the one with that global id – Gigi Feb 16 at 20:42
  • In light of the More Context you added, why do you need an identifier for each unique open? What are you trying to accomplish after this? – Brian Miller Feb 16 at 21:26

Your Answer

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

Browse other questions tagged or ask your own question.