How to get helper in oncreate

I’m using Template subscribe in oncreate.
If I want to get the helper value I have to use Template.currentData() which is reactive.
And when I use it with Tracker. The console just keep getting the data.

var parentType = Template.instance().parentType;
self.autorun(function(){
console.log(parentType);
})

Sorry, I don’t understand. Maybe you can provide a piece of non-working code?

Template.volunteerTakeInsert.onCreated(function(){
var self = this;
// self.state
var parentType = Template.currentData().parentType;
var parent_id = Template.currentData().parent_id;
self.autorun(function(){
var volunteerTake;
if( parentType!=undefined
&& parent_id !=undefined ){
console.log(parentType);

And that the console will push hundreds of times

What do you want to achieve?

I get two helper passing by the parent helper : parentType and parent_id.
I want to use this two helper to controlthe subscription in volunteerTakeInsert.

First I can’t get helper in oncreated
so I use currentData.

But it renders hundreds time in the autorun

Nothing in the code you posted would trigger the autorun hundreds of times. I suggest you create a meteorpad to show your problem.

I suggest googling how to check undefined status.
And show us how you render that template so we see how you pass the variables.

1 Like

Thanks I got it working. My fault!