my set params is null for some reason. But the variables i'm passing in do have values. I have a console.log before I set params to check before the parameters are set to their values.

Can anyone spot something wrong in my code?`

onDrop: function(component, event, helper)

    var index = component.get('v.index');
    var seatNumber = component.get('v.seatNumber');
    console.log("Target Item Index:",index,"\nTarget Item Seat:",seatNumber); //These work, and have values.

    var cardSwapEvent = component.getEvent('CardOnCardSwap');
    cardSwapEvent.setParams({'seatNumber': seatNumber, index: index}); //This complains "Cannot read property 'setParams' of null"


Console output:

Moved Item index: 0 Moved Item Seat: 1 Card.js:26 Target Item Index: 1 Target Item Seat: 2

Error message:

This page has an error. You might just need to refresh it. Action failed: c:Card$controller$onDrop [Cannot read property 'setParams' of null] Failing descriptor: {c:Card$controller$onDrop}

  • index: index ? => 'index' : index (quick observation)
    – glls
    Commented Oct 10, 2018 at 14:19
  • I've changed that typo, but I still have the same error message after refreshing preventing my event from firing. Commented Oct 10, 2018 at 14:21
  • 2
    Can you also include your aura:registerEvent line from .cmp? Commented Oct 10, 2018 at 14:22
  • <!-- Custom Events --> <aura:registerEvent name="cardSwapRegister" type="c:CardSwap"/> Commented Oct 10, 2018 at 14:22
  • 5
    The name attribute while registering and handling a component event should be exactly the same. Seems you declared the event name in your registering component as cardSwapRegister and then in handler you have it as cardSwapped, that will not work. Also can you please add the snippet from the comments to your question, that will help to get the full context here.
    – Jayant Das
    Commented Oct 10, 2018 at 14:31

1 Answer 1


Looking at your question and comments, I can see following issues. I will strongly recommend to edit your question to put every details in the original post.

  1. You have declared the name of the component event in your registering lightning component as cardSwapRegister
  2. You are trying to set the parameters on the component event in your JS controller using the name as CardOnCardSwap
  3. You have declared the component event in your handler lightning component as cardSwapped

None of the names at any place matches and thus you are encountering the issue where you are not able to set the values, and retrieve the values.

For component events, you communicate between your lightning components using the name. That means that the name in your registering LC and the handler LC should be always same. And that you use the same name in any of the JS controllers too.

This is from the documentation:

The name attribute in <aura:handler> must match the name attribute in the tag in the component that fires the event.

Once you fix the naming issues across the components, you should be able to have it working.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .