array

React: Cannot access index of an array in a state (index undefined)

匿名 (未验证) 提交于 2019-12-03 08:30:34
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have an array as a state property in my component, like this: this.state = { postData: [{id: 1, author: 'Mary'}, {id:2, author: 'John'}] } When I access it through console.log , such as this.state.postData[0] , it shows the contents of the object and works correctly But when I try to output it as a content of an element, this way: <p>{this.state.postData[0].author}</p> It says that this.state.postData[0] is undefined. I so far have not been able to find out why it happens, is there some special way to access arrays in React? EDIT:

react-redux update item in array doesn't re-render

匿名 (未验证) 提交于 2019-12-03 08:30:34
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I have a reducer which returns an object with an array in the object. I render the list of items in the array and when the user clicks on that item I want to re-render the array (or at least the item). I've created a jsbin that shows the problem: https://jsbin.com/fadudeyaru/1/edit?js,console,output To reproduce the issue, click the + or - button a few times to create a history. then click on one of the history items. you'll notice that the console log notices the event, and updates the state, but the list is not re-rendered. This

Getting data from ctypes array into numpy

匿名 (未验证) 提交于 2019-12-03 08:30:34
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I am using a Python (via ctypes ) wrapped C library to run a series of computation. At different stages of the running, I want to get data into Python, and specifically numpy arrays. The wrapping I am using does two different types of return for array data (which is of particular interest to me): ctypes Array : When I do type(x) (where x is the ctypes array, I get a in return. I know that this data is a copy of the internal data from the documentation and I am able to get it into a numpy array easily: >>> np . ctypeslib . as_array

Sorting array based on date and time with two dictionary keys

匿名 (未验证) 提交于 2019-12-03 08:30:34
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I am trying to sort an array based on date and time , I can successfully sort the array based on date both time is coming as another value in dictionary. So date comes as a string in format "yyyy-MM-dd" and time comes in as a string in format "HH:mm" Time value comes in key "starts" as string '"HH:mm"' format. I know somehow I need to combine two strings to 'yyyy-MM-dd HH:mm' but how? -( NSMutableArray *) sortArrayBasedOndate :( NSMutableArray *) arraytoSort { NSDateFormatter * formatter = [[ NSDateFormatter alloc ] init ]; [

ArrayList and HashSet insert performance test result confuse me

匿名 (未验证) 提交于 2019-12-03 08:30:34
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: i wirte a class to test the insert performance between arraylist and hashset,as i expect ,the hashset insert performance will be much better than arraylist(maybe the book deceived me),but the test result make me so confused HashSet<String> hashSet = new HashSet<String>(); long start = System.currentTimeMillis(); for (int i = 0; i < 900000; i++) { hashSet.add(String.valueOf(i)); } System.out.println("Insert HashSet Time: " + (System.currentTimeMillis() - start)); ArrayList<String> arrayList = new ArrayList<String>(); start = System

C++: .bmp to byte array in a file

匿名 (未验证) 提交于 2019-12-03 08:30:34
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: Yes i have been through the other questions that are related to this, but i found them not much help. They were some help but i am still a bit confused. So here what what i need to do: We have a 132x65 screen. I have a 132x65 .bmp. I want to go through the .bmp and separate it into little 1x8 columns to get the binary of that 32-bit column. Then do that 132 times across, and do that 9 times down. Anything that is not white should be counted as a bit. example: If the top left pixel of the picture is any color that is not white and

CALayerArray was mutated while being enumerated

匿名 (未验证) 提交于 2019-12-03 08:30:34
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have to delete an object of an array every now and then, when I do it I get this error. Collection < CALayerArray: 0xc4f3b20> was mutated while being enumerated The error appears on this method, which is the accesor of the Array: - (NSArray *)occupantsArray { if (dispatch_get_current_queue() == moduleQueue) { return occupantsArray; } else { __block NSArray *result; dispatch_sync(moduleQueue, ^{ //ON THIS LINE result = [occupantsArray copy]; }); return [result autorelease]; } } As you can see Im taking care of not returning the original

How to send complex types from PHP SoapClient to ASP.NET SOAP server?

匿名 (未验证) 提交于 2019-12-03 08:30:34
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Hello I'm having problems sending arrays, structs and arrays of structs from PHP to an ASP.NET SOAP server... Anyone have a sollution for this? I've googled for days and any sollution worked for me. Perphaps I'm forgetting something... There are examples of my code: $client = new SoapClient($options); $pCriteria = new stdClass(); $pCriteria->type=1; $pCriteria->capacity=4; //Test 1 (fail): $resp = $client->GetRooms(array("pCriteria"=>$pCriteria)); //Test 2 (fail): $resp = $client->GetRooms(array("pCriteria"=>new SoapVar($pCriteria, SOAP_ENC

C++ Array Shuffle

匿名 (未验证) 提交于 2019-12-03 08:28:06
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm fairly new to C++ and don't quite understand function parameters with pointers and references. I have an array of Cards that I want to shuffle using the Fisher-Yates shuffle. The deck is declared as Card *deck[deckSize]; where deckSize has been declared as 24. The array is then initialized. I then call the shuffle function: void shuffle (Card * deck[]) { int deckSize = 24; while (deckSize > 1) { long int k = lrand48(); k = k %24; deckSize--; Card * temp = deck[deckSize]; deck[deckSize] = deck[k]; deck[k] = temp; } } If I try to print the

How to add to json array in .json file with php

匿名 (未验证) 提交于 2019-12-03 08:28:06
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: How do I add to a .json file with php? Currently, I'm appending a .json file with php, but it won't add the data to an existing json object. It makes a new object. I need the data all stored in one object, in an external JSON file. Basically, I have a json object and want to add more values to it. Thanks Current Code <?php $username = mysql_real_escape_string($_POST['username']); $password = mysql_real_escape_string($_POST['password']); $sql="SELECT * FROM accounts WHERE uname = '$username' AND pword = '$password'"; $r = mysql_query($sql);