javascript - waiting forEach to finish using setState in react

How do I wait for setState in a foreach to finish then show the render?class App extends Component { componentDidMount() { someArrOfObject.forEach(o => { this.setState({ [`list_for_${}`]: o.val }) }) } render() { const { selected_id } = this.state const selected_list = this.state[`list_for_${selected_id}`] return => <div>{o.val}</div>) }}...Read more

javascript - React/Redux - How to invoke a second function in componentDidMount after the first one finishes fetching AJAX

I have this React-Native app, which fetches a list of items, and then, an image gallery for each of those items. So basically, I have two ajax function, and the second one needs the list of items fetched in the first function.I make the first invoke in componentDidMount(), but I don't know how to "wait" for it to finish to make the second call. If I just place them one after the other, the second one won't do anything because there is no list of items yet.How can I solve this? I read similar questions here on StackOverflow but couldn't find a c...Read more

javascript - Get data from an input inside a table

Hi guys I'm trying to get the value of an input in my table, the problem is that I'm creating new rows dynamically by a button, these get the new ids and everything.I'm getting the value by an blur event , but this one only gets the value when the main input loses the focus, but gets the data of the second input (if I've created a new one)I want to get the data when the right input loses the focusMy table<table class="table table-striped table-bordered" id="tabla_transferencia"> <thead> <tr> <th style...Read more

javascript - Discord.js Arguments With Spaces

So I'm trying to create my bot and I want there to be a command which adds information to a sqlite database (command === "addplayer") { message.delete() let [name, crew, rank, weapon, df, talent, profession, other] = args; if(!name) return"Name argument is required!"); let id = name.toLowerCase(); if(!crew) {let crew = "Blank";} if(!rank) {let rank = "Blank";} if(!weapon) {let weapon = "Blank";} if(!df) {let df = "Blank";} if(!talent) {let talent = "Blank";} if(!...Read more

javascript - Using firebase query-based rules to secure data (with orderByChild and an un-indexable key)

Update / Answer Feb 2018It seems Query-based rules are currently unable to afford this level of security / elegance to the realtimeDB structure. Something like this would require nested sorting, variable 'key' indexes (as with the current "indexOn": ".value", or some other magic yet to be dreamed up by the firebase team.In the meantime I can definitely recommend reading up on query-based rules: more

javascript - React Native - LayoutAnimation: how to make it just animate object inside component, not whole component/view?

I'm trying to follow this example (code here) and employ LayoutAnimation inside my RN project (the difference from that example being that I just want to render my circles with no button that'll be pressed).But when I've added LayoutAnimation, it's the whole view/screen/component that does the animation of 'springing in', not just the circles as I desire. Where do I have to move LayoutAnimation to in order to achieve just the circle objects being animated? UPDATED AGAIN: Heeded bennygenel's advice to make a separate Circles component and then o...Read more

javascript - Define "display" css property upon jQuery/JS toggle

I'm toggling between two divs with jQuery (I'm new to jQuery...) and I want both divs to use the display: flex property. I'm able to assign it to the first/default toggle (Option 1), but the second toggle (Option 2) defaults to display: block, and I'm not sure how to hook onto that.Any insight would be so helpful - thanks! Here's a jsfiddle:<div class="pricing-switcher"> <a class="toggle active" id="HS-College">High School and College</a> <a class="toggle" id="Club-Youth">Club and Y...Read more

javascript - ag-grid row sorting for custom cellRenderer data

I'm, trying to implement column sorting on cell data that contains custom HTML, so I'm presuming that I need to implement a custom function to override the normal sorting routine and point it to the raw values rather than the HTML rendered output.I'm not able to gather from the ag-grid documentation how I do this, I see which describes a solution to my problem, but the explanation and sample code aren't helping me figure this out. It looks like I need a comparator, but in their example about date...Read more

javascript - My ag-grid doesnt show up any Data

Im fairly new to Angular/Typescript. Im kinda learning and developing at the same time. Im trying to build a grid with data loaded from a Json file and Im having some issues with showing my Data. I'd love if you guys could point to my error, cuz my code compiles with no errors and Im kinda helpless at the moment. Ill provide my code below.Thanks in{ selector: 'app-my-grid-application', templateUrl: './my-grid-application.component.html'})export class MyGridApplicationComponent { private gri...Read more

Passing a JavaScript string to a Rust function compiled to WebAssembly

I have this simple Rust function:#[no_mangle]pub fn compute(operator: &str, n1: i32, n2: i32) -> i32 { match operator { "SUM" => n1 + n2, "DIFF" => n1 - n2, "MULT" => n1 * n2, "DIV" => n1 / n2, _ => 0 }}I am compiling this to WebAssembly successfully, but don't manage to pass the operator parameter from JS to Rust.The JS line which calls the Rust function looks like this:instance.exports.compute(operator, n1, n2);operator is a JS String and n1, n2 are JS Numbers.n1 and n2 are passed...Read more

javascript - How to use Animtrap CSS with Page Scroll

I want to create an animation with scroll page, so I created a javascript using with AnimTrap I tried with this code for including animscroll.js <head><title>AnimTrap Example</title><link href="external_css/animtrap.css" rel="stylesheet"><script src=""></script><script src="external_css/anim-effect.js"></script><script src="external_css/anim-scroll.js"></script><script>ANIMSCROLL.init({ easing: 'ease-in-out-sine'});</script&...Read more