javascript

React - react-scripts publicPath

血红的双手。 提交于 2021-02-20 19:00:12
问题 Is there possibility to override publicPath in react-scripts for dev env. I use symfony and I include react app inside twig so I had to change assets to serve from http://localhost:3000/static/js/bundle.js - this works fine but I have problem with static files because they are rendered in browser as '/static/media/logo.813ua.png' and my current url is http://localhost:8000 What I did is I run yarn eject and modify in webpack.config.dev.js: var publicPath = 'http://localhost:3000/' and

Syntax error using => in IE [duplicate]

試著忘記壹切 提交于 2021-02-20 18:58:15
问题 This question already has answers here : Syntax error in IE using ES6 arrow functions (2 answers) Closed 3 years ago . I have the following line of javascript code var res = Object.keys(packages).filter(e => packages[e] === true) The above works well in all the other browser apart from IE. IE complains about Syntax erro at => can someone tell me how to get around this in IE 回答1: IE must not support arrow-functions. Just use the old function keyword. .filter(function(e){ return packages[e] ===

Syntax error using => in IE [duplicate]

廉价感情. 提交于 2021-02-20 18:57:15
问题 This question already has answers here : Syntax error in IE using ES6 arrow functions (2 answers) Closed 3 years ago . I have the following line of javascript code var res = Object.keys(packages).filter(e => packages[e] === true) The above works well in all the other browser apart from IE. IE complains about Syntax erro at => can someone tell me how to get around this in IE 回答1: IE must not support arrow-functions. Just use the old function keyword. .filter(function(e){ return packages[e] ===

child_added gets triggered after remove

两盒软妹~` 提交于 2021-02-20 18:50:48
问题 I've created this handler to watch for new children being created. This little trick stops the child_added event from triggering my code on each page load. Instead it only gets triggered when something is actually added. // Listen for new rooms being created var first_room_added_after_load = true; this._roomRef.endAt().limit(1).on('child_added', function(snapshot){ if (first_room_added_after_load) { // we want to skip the first room, because it will already exist first_room_added_after_load =

YouTube API playlist shuffle not working?

烈酒焚心 提交于 2021-02-20 18:50:20
问题 I have been trying to set-up my youtube api to shuffle my playlist but the order is the same all the time... Here is the link where I am getting my code from https://developers.google.com/youtube/iframe_api_reference#setShuffle Am I calling it right? here is my code below <div id="player"></div> <script> var tag = document.createElement('script'); tag.src = "https://www.youtube.com/iframe_api"; var firstScriptTag = document.getElementsByTagName('script')[0]; firstScriptTag.parentNode

javascript client to Python server: XMLHttpRequest responseText is empty after Get request

佐手、 提交于 2021-02-20 18:50:12
问题 I am trying to write a chrome extension which is able to send/receive data to/from a python server script. Currently, I am at the point where the js script is making a GET request okay, the only issue being that the .responseText is always empty (even though the python script is responding with text). popup.js document.addEventListener('DOMContentLoaded', function() { var xhr = new XMLHttpRequest(); xhr.onreadystatechange = function() { if (xhr.readyState == xhr.DONE) { var resptxt = xhr

Typescript/babel import causing “_1.default is not a function”

心已入冬 提交于 2021-02-20 18:46:58
问题 I am trying to use https://github.com/timmywil/panzoom from a typescript project compiled with webpack and babel. The problem is that the typescript method call: import Panzoom from '@panzoom/panzoom'; Panzoom(document.querySelector("#pic")); is transpiled to the following javascript: panzoom_1.default(document.querySelector("#pic")); which then generates the following run-time error: Uncaught TypeError: panzoom_1.default is not a function If I debug the javascript then panzoom_1 has the

websocket server, storing the data

别说谁变了你拦得住时间么 提交于 2021-02-20 18:46:57
问题 Lets say that i make a websocket server chat (node.js + socket.io). How would i store the chat messages, so that when a "new" user joins the chat, he will be seeing old chat messages, and not just the ones which has been sent while hes in the chat. Should the data be stored in variables in the server? Something like: var io = require('socket.io').listen(80); var saveData = { }; io.sockets.on('connection', function (socket) { socket.emit('news', { hello: 'world' }); socket.on('my other event',

Typescript/babel import causing “_1.default is not a function”

旧巷老猫 提交于 2021-02-20 18:46:55
问题 I am trying to use https://github.com/timmywil/panzoom from a typescript project compiled with webpack and babel. The problem is that the typescript method call: import Panzoom from '@panzoom/panzoom'; Panzoom(document.querySelector("#pic")); is transpiled to the following javascript: panzoom_1.default(document.querySelector("#pic")); which then generates the following run-time error: Uncaught TypeError: panzoom_1.default is not a function If I debug the javascript then panzoom_1 has the

websocket server, storing the data

为君一笑 提交于 2021-02-20 18:44:24
问题 Lets say that i make a websocket server chat (node.js + socket.io). How would i store the chat messages, so that when a "new" user joins the chat, he will be seeing old chat messages, and not just the ones which has been sent while hes in the chat. Should the data be stored in variables in the server? Something like: var io = require('socket.io').listen(80); var saveData = { }; io.sockets.on('connection', function (socket) { socket.emit('news', { hello: 'world' }); socket.on('my other event',