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
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
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
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
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #hex









