Skip to content

πŸ› Bug Report: Not able to use @novu/js with solid-jsΒ #10078

@paulwer

Description

@paulwer

πŸ“œ Description

When using solid-js the @novu/js package does not work, we get the following error:

dev.js:1029  Uncaught ReferenceError: React is not defined
    at MotionComponent (index.jsx:103:3)
    at dev.js:586:12
    at untrack (dev.js:475:12)
    at Object.fn (dev.js:582:37)
    at runComputation (dev.js:742:22)
    at updateComputation (dev.js:724:3)
    at devComponent (dev.js:593:3)
    at createComponent (dev.js:1311:10)
    at index.mjs:2194:12
    at dev.js:586:12

πŸ‘Ÿ Reproduction steps

create Inbox component:

import { Component, createEffect, createSignal, on, onCleanup, Show } from "solid-js"
import { useNovu } from "./useNovu"

const NovuInbox: Component = () => {
    const { subscriberInput, novuUI } = useNovu()
    const [mountElement, setMountElement] = createSignal<HTMLDivElement | null>(null)

    let mountedNovuUI: ReturnType<typeof novuUI> = null

    createEffect(
        on([mountElement, subscriberInput, novuUI], ([element, subscriber, nextNovuUI]) => {
            if (!element || !subscriber || !nextNovuUI) {
                return
            }

            if (mountedNovuUI === nextNovuUI) {
                return
            }

            if (mountedNovuUI) {
                mountedNovuUI.unmountComponent(element)
                mountedNovuUI.unmount()
                element.innerHTML = ""
            }

            nextNovuUI.mountComponent({
                name: "Inbox",
                element,
            })

            mountedNovuUI = nextNovuUI
        }),
    )

    onCleanup(() => {
        const element = mountElement()
        if (mountedNovuUI && element) {
            mountedNovuUI.unmountComponent(element)
        }
        mountedNovuUI?.unmount()
        mountedNovuUI = null
    })

    return (
        <Show when={subscriberInput()}>
            <div ref={setMountElement} />
        </Show>
    )
}

export default NovuInbox

πŸ‘ Expected behavior

Load as expected.

Is there may something, we are doing wrong?

πŸ‘Ž Actual Behavior with Screenshots

Image component loads, but as soon as it is tried to open, it fails

Novu version

3.13.0

npm version

No response

node version

No response

πŸ“ƒ Provide any additional context for the Bug.

No response

πŸ‘€ Have you spent some time to check if this bug has been raised before?

  • I checked and didn't find a similar issue

🏒 Have you read the Contributing Guidelines?

Are you willing to submit PR?

None

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions