Question: I am using a navgation drawer in Android to select between different fragments.
Fragment A has user interface.
Fragment B has bluetooth scan.

User goes to Fragment B, does a scan and connect to device, shows its connected to a device

Goes to Fragment A. 

On returning back to Fragment B it replaces screen as brand new and not connected

Is there a way of the fragment to remember its last state before switching to another Fragment. Or is this better as a activity?

Apologies if this has been asked before or a basic question. First time using Fragments and getting the hang of them.

Thanks in advance

Answer: 
You have three problems in your code :

1. The `while` loop is too fast for you to see any motion. To fix this, I proposed a `setInterval` solution below.
2. You are giving `style` to the `<Proba>` component thinking it's the default HTML attribute. It's in fact nothing but a prop, the solution below fixes that as well.
3. You are placing spaces around the `=` signs in the defintion of your props and that is not recommended.

Here is the render method of the `Proba` component :

```
function render() {
    return (
        // set the style as a normal prop, it will work here because this
        // is a simple <div>, not a component
        <div ref="kwadrat" id="kwadrat" style={ this.props.style }>
            kwadrat
        </div>
    );
}

```

Here is the `fadeIn` method :

```
fadeIn() {
    const interval = setInterval(() => {
        this.setState({ h: (this.state.h + 5) });
        if (this.state.h >= 400) {
            clearInterval(interval);
        } 
    }, 50);
}

```

I have added a [codepen](https://codepen.io/glouhaichi/pen/WZOOwo) that shows a working example, in which I have added two different configurations for the movement of the `<div>` (`step` and `time`).
First I want you to give you tipps to optimize your code:

Use arrow functions instead of bind():

```
this.fadeIn = () => this.fadeIn();

```

In this case it would be enough to just call the method like:

```
this.fadeIn();

```

Can you give me more informations about what do you want to do and how the components are structured (parent/child). I would never use document.getElementById in a React App...