AntoineW / luge

Luge
290 stars 10 forks source link

@chotardlucien I just tried to import luge through a component using useEffect and I can make it work in both develop and build mode. #10

Closed CrispinMartens closed 2 years ago

CrispinMartens commented 2 years ago

@AntoineW

I created a luge.js component like this:

import { useEffect } from "react"

const LugeReact = () => {
  useEffect(() => {
    import("@waaark/luge/dist/js/luge")
      .then((luge) => {
        luge.lifecycle.refresh()
      })
      .catch((error) => console.error(error));
  })

  return (null);
}

export default LugeReact

And then use it in my pages and it seems to work fine. Did you manage to get through the build error? What kind of issue do you have now?

Originally posted by @AntoineW in https://github.com/AntoineW/luge/issues/5#issuecomment-937645159

CrispinMartens commented 2 years ago

I followed this procedure to get Luge to work without throwing an' SyntaxError: Unexpected token 'export'' Error inside a Next JS Application.

But every element that I wrap inside a tag, disappears and is not rendered, regardless of the data-lg attribute added:

https://codesandbox.io/s/naughty-haslett-wzub3?file=/pages/index.js

Is there anything more necessary to instantiate Luge?

AntoineW commented 2 years ago

Hi, Here is a Next.js + luge sandbox https://codesandbox.io/s/magical-ramanujan-3njk4

Does it help?