Question: My Loading component:

```
import React from 'react'

export default class Loading extends React.Component {
    constructor(props) {
        super(props)
        this.state = {
            display: 'none'
        }
    }

    render() {
        return (
            <div className="loading" style={{display: this.state.display}}>
                <span></span>
            </div>
        )
    }
}

```

And I want change `display` from `App.js`

```
Loading.setState ...

```

Or

```
var lng = new Loading()
lng.setState ...

```

Both of them not work

I want can change state from another class or function

Answer: 
If you want to change `display` from `App.js`:

1. Pass it as prop to `Loading` component, and keep the state at `App.js`.
2. pass some prop from `App.js` and when it changes - change the state
of `display` in `App.js`
3. Use some global state/store manager like [Redux](https://react-redux.js.org/introduction/getting-started) or built-in [useContext](https://reactjs.org/docs/hooks-reference.html#usecontext) react-hook, in this case you will be able to change from any component connected to store
[Solution sample](https://codesandbox.io/s/gallant-mccarthy-xf98m?file=/src/App.js:0-485)

A simple solution can be found in a code sandbox example.