state

React.Component vs React.PureComponent

久未见 提交于 2019-11-27 19:40:54
问题 The official React docs state that " React.PureComponent 's shouldComponentUpdate() only shallowly compares the objects", and advises against this if state is "deep". Given this, is there any reason why one should prefer React.PureComponent when creating React components? Questions : is there any performance impact in using React.Component that we may consider going for React.PureComponent ? I am guessing shouldComponentUpdate() of PureComponent performs only shallow comparisons. If this is

How are mutable arrays implemented in Haskell?

◇◆丶佛笑我妖孽 提交于 2019-11-27 19:21:22
I've read many research papers on this topic, and they usually argue that arrays are implemented using Monads. But none of these papers gave a clear definition of how the "type" Array itself should be defined, they only gave definitions for the functions using monads to access or modify this type. How are arrays, having O(1) time to access or modify an indexed element, implemented in Haskell ?! (such as STUArray and MArray) How are arrays, having O(1) time to access or modify an indexed element, implemented in Haskell They are implemented via primitive operations in the runtime system for

Remove TinyMCE control and re-add

随声附和 提交于 2019-11-27 18:25:56
问题 I have a js application that never reloads the page, so when navigating I need to remove TinyMCE controls entirely, and then I want to re-initialize when navigating to an area that needs it. I tried the accepted answer to this question, but it seems to do nothing. How do i remove tinyMCE and then re-add it? tinymce.EditorManager.execCommand('mceRemoveControl',true, editor_id); and my specific implimentation: //if I throw an alert here, it does get called, so I know it's not null if (tinyMCE

React - setState() on unmounted component

半世苍凉 提交于 2019-11-27 18:04:12
In my react component im trying to implement a simple spinner while an ajax request is in progress - im using state to store the loading status. For some reason this piece of code below in my React component throws this error Can only update a mounted or mounting component. This usually means you called setState() on an unmounted component. This is a no-op. Please check the code for the undefined component. If I get rid of the first setState call the error goes away. constructor(props) { super(props); this.loadSearches = this.loadSearches.bind(this); this.state = { loading: false } }

setInterval in a React app

烈酒焚心 提交于 2019-11-27 17:33:59
I'm still fairly new at React, but I've been grinding along slowly and I've encountered something I'm stuck on. I am trying to build a "timer" component in React, and to be honest I don't know if I'm doing this right (or efficiently). In my code below, I set the state to return an object { currentCount: 10 } and have been toying with componentDidMount , componentWillUnmount , and render and I can only get the state to "count down" from 10 to 9. Two-part question: What am I getting wrong? And, is there a more efficient way of going about using setTimeout (rather than using componentDidMount &

How to persist objects between requests in PHP

為{幸葍}努か 提交于 2019-11-27 17:29:16
问题 I've been using rails, merb, django and asp.net mvc applications in the past. What they have common (that is relevant to the question) is that they have code that sets up the framework. This usually means creating objects and state that is persisted until the web server is recycled (like setting up routing, or checking which controllers are available, etc). As far as I know PHP is more like a CGI script that gets compiled to some bytecode each time it's run, and after the request it's

ASP.Net MVC and state - how to keep state between requests

陌路散爱 提交于 2019-11-27 17:26:32
As a fairly experienced ASP.Net developer just recently starting using MVC, I find myself struggling a bit to change my mindset from a traditional "server control and event handler" way of doing things, into the more dynamic MVC way of things. I think I am slowly getting there, but sometimes the MVC "magic" throws me off. My current scenario is to create a web page that allows the user to browse a local file, upload it to the server and repeat this until he has a list of files to work with. When he is happy with the file list (which will be displayed in a grid on the page), he will click a

CTCallCenter - Call Event Handler - in background state

我怕爱的太早我们不能终老 提交于 2019-11-27 15:22:17
Regarding the Apple documentation there is no way to handle the phone state while the app is suspended: https://developer.apple.com/documentation/coretelephony/ctcallcenter "While it is suspended, your application does not receive call events" Is this also true for the "background" state? (As the background state is not the same with the "suspended" app state regarding the states described in the Apple documentation) https://web.archive.org/web/20140824215114/https://developer.apple.com/library/ios/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/ManagingYourApplicationsFlow

Android ListView State List not showing default item background

放肆的年华 提交于 2019-11-27 14:50:01
问题 Have read over a number of related questions here at SO, as well as looked through the Android docs and source to try to figure this out, but I am stumped, although given that the listSelector seems to only apply styles on selected items, I'm not shocked... I have a Listview defined in main.xml here: <?xml version="1.0" encoding="utf-8"?> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent"> <ListView

android button setPressed after onClick

陌路散爱 提交于 2019-11-27 14:46:33
yesterday I noticed the possibility to integrate Fragments in older API Levels through the Compatibility package, but thats not really essential for the question. :) I have a Button with an OnClickListener Button button = (Button) findViewById(R.id.button); button.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { doSomething(); button.setPressed(true); } }); Because of the actual clicking, it is shown as pressed and after releasing the click, the button state is not pressed and stays that way. Is there a simple way that keeps the button state pressed after