Sidi_Mohammed

Sidi_Mohammed

LiveView stop working because of one import in app.js

Hello,
I have imported a javascript library to app.js and creating an instance from this library, however that stop LiveView from working, and a live route behaves like a regular http route

import {SomeObject} from "MyLibrary"
const someObject = new SomeObject()

Iam really wondered what can cause this strange behaviour, there is no errors or warnings at all, and once I put those 2 lines in a comment, everything returns to work normally including LiveView, also I confirmed that the library and the constructor works normally for another frameworks so where is the problem please ?

Marked As Solved

garrison

garrison

The app.js script contains code which establishes the socket connection to the Phoenix server. In JavaScript (and most languages) an error halts execution of the program, so the connection is not established. If there is no connection LiveView will not work.

Also Liked

tcoopman

tcoopman

We’re going to need a bit more information than that to help you.
Can you show the full app.js file? What is the library? Are there any console errors in the browser?
Do you get past the constructor in your js file?

tcoopman

tcoopman

can you maybe push a reproduction of the issue in that case?

kokolegorille

kokolegorille

You should show this js file…

You should be more explicit… do You have error logs?

Are You manipulating DOM in your library?

Why You choose to put the code in apps.js instead of a hook? Maybe it is live_view updating the DOM

Where Next?

Popular in Questions Top

Emily
I have VueJS GUIs with the project generated using Webpack. I have Elixir modules that will need to be used by the VueJS GUIs. I forese...
New
lastday4you
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
komlanvi
Hi everyone, I was playing with phoenix liveView but I run into an issue. I have a form and want to validate each input text when the te...
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New

Other popular topics Top

KronicDeth
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine) This is a plugin that adds support for Elixir to JetBrains IntelliJ...
289 36654 110
New
JakeBecker
TL;DR: I’ve just released an implementation of Microsoft’s IDE-independent Language Server Protocol for Elixir. It adds language support ...
1144 54921 245
New
greenz1
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
New
sorentwo
Hello! tl;dr Announcing Oban, an Ecto based job processing library with a focus on reliability and historical observability. After spen...
985 44532 311
New
msaraiva
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
564 44139 214
New
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New

We're in Beta

About us Mission Statement