AntoineW / luge

Luge
290 stars 10 forks source link

Custom Reveals seem not to work anymore since version beta-0.6.3 #16

Closed blzzz closed 2 years ago

blzzz commented 2 years ago

After upgrading from beta-0.6.1 to beta-0.6.3 the following code caused an error saying TypeError: Cannot read properties of undefined (reading 'in'):

luge.reveal.add('in', 'triggerNav', updateNav)

This did work before. I'm calling it inside a React.useEffect function, that depends on the luge object. Is it more proper to call it in a lifecycle listener à la luge.lifecycle.add('pageInit', () => registerMyCustomReveals(luge))?

blzzz commented 2 years ago

Just realised that this works as intended (I forgot to call done()):


function registerMyCustomReveals(luge) {
    luge.reveal.add('in', 'triggerNav',() => { ... });
}

... loading luge ... 

React.useEffect( () => {
   luge.lifecycle.add('pageInit', (done) => {
      registerMyCustomReveals(luge)
      done()
  })
}, [luge])

Means that I better wait for the lifecycle call, correct?

AntoineW commented 2 years ago

It's a bug that I have to fix, I'm working on a new version. But for now it's ok to add your reveals from a lifecycle hook, the siteInit one should do the job.

AntoineW commented 2 years ago

@blzzz this bug should be fixed by new version 0.6.5-beta 🙏

blzzz commented 2 years ago

Perfect – thanks a lot, @AntoineW. I'll give it a try.

blzzz commented 2 years ago

It works!