React – setState() on unmounted component

Without seeing the render function is a bit tough. Although can already spot something you should do, every time you use an interval you got to clear it on unmount. So: componentDidMount() { this.loadInterval = setInterval(this.loadSearches, this.props.pollInterval); } componentWillUnmount () { this.loadInterval && clearInterval(this.loadInterval); this.loadInterval = false; } Since those success and error callbacks might … Read more

Android save Checkbox State in ListView with Cursor Adapter

I had the same issue myself: how to toggle multiple select CheckedTextView in a custom layout (i.e not using android.R.layout.simple_list_item_multiple_choice) The following worked for me. The example I have is a custom view that is provided an adaptor extended from SimpleCursorAdapter. My custom view (row_contact.xml): <?xml version=”1.0″ encoding=”utf-8″?> <FrameLayout xmlns:android=”http://schemas.android.com/apk/res/android” android:layout_height=”wrap_content” android:layout_width=”fill_parent”> <CheckedTextView android:id=”@android:id/text1″ android:layout_width=”fill_parent” … Read more

TypeError: evt.target is null in functional setState

These are two different syntaxes for setState First: handleOnChange(evt) { this.setState(() => ({ tickerName: evt.target.value })); } uses the updater function as the first argument. Second: handleOnChange(evt) { this.setState({ tickerName: evt.target.value }); } uses the object to be updated When using the synthetic event in the updater function you need to use event.persist() From the … Read more

Android different EditText backgrounds for different states using shapes, selector or list

I suggest to use NinePatch images to customize your EditText. Here goes an example based on my code: The Selector: <selector xmlns:android=”http://schemas.android.com/apk/res/android”> <item android:state_window_focused=”false” android:state_enabled=”true” android:drawable=”@drawable/twitter_im_edittext_normal” /> <item android:state_window_focused=”false” android:state_enabled=”false” android:drawable=”@drawable/twitter_im_edittext_normal” /> <item android:state_pressed=”true” android:drawable=”@drawable/twitter_im_edittext_normal” /> <item android:state_enabled=”true” android:state_focused=”true” android:drawable=”@drawable/twitter_im_edittext_focused” /> <item android:state_enabled=”true” android:drawable=”@drawable/twitter_im_edittext_normal” /> <item android:state_focused=”true” android:drawable=”@drawable/twitter_im_edittext_focused” /> <item android:drawable=”@drawable/twitter_im_edittext_normal” /> </selector> Use selector … Read more

Resetting the State of a Stream

The code here std::cin.clear(std::istream::failbit); doesn’t actually clear the failbit, it replaces the current state of the stream with failbit. To clear all the bits, just call clear(). The description in the standard is a bit convoluted, stated as the result of other functions void clear(iostate state = goodbit); Postcondition: If rdbuf()!=0 then state == rdstate(); … Read more