---
title: "Comment by Serdar Sanri on \"How to make a global Component ( Loader, Alert, Toast, etc ) in React Native\" | Hashnode"
description: "I am not confident enough to think it is a good idea to expose it globally. If you are already using context, that smells fishy to me."
url: "https://hashnode.com/posts/how-to-make-a-global-component-loader-alert-toast-etc-in-react-native/5d1306582bbe104f674b26a3/comment/5d142f8ce05827334f68cb61"
---

[Discussion](https://hashnode.com/posts/how-to-make-a-global-component-loader-alert-toast-etc-in-react-native/5d1306582bbe104f674b26a3)

Comment [How to make a global Component ( Loader, Alert, Toast, etc ) in React Native](https://hashnode.com/posts/how-to-make-a-global-component-loader-alert-toast-etc-in-react-native/5d1306582bbe104f674b26a3)

[Serdar Sanri](https://hashnode.com/@ssanri)

[Jun 27, 2019](https://hashnode.com/posts/how-to-make-a-global-component-loader-alert-toast-etc-in-react-native/5d1306582bbe104f674b26a3/comment/5d142f8ce05827334f68cb61)

I am not confident enough to think it is a good idea to expose it globally. If you are already using context, that smells fishy to me.

[Satish Rajbhar](https://hashnode.com/@satissraj)

[Jun 29, 2019](https://hashnode.com/posts/how-to-make-a-global-component-loader-alert-toast-etc-in-react-native/5d1306582bbe104f674b26a3/comment/5d142f8ce05827334f68cb61#reply-5d17d180a31cb51f4f2cf38f)

Yes, you are right. Now added the note in step 2. Thanks

[Kailash Uniyal](https://hashnode.com/@juggernaut23)

[Apr 5, 2020](https://hashnode.com/posts/how-to-make-a-global-component-loader-alert-toast-etc-in-react-native/5d1306582bbe104f674b26a3/comment/5d142f8ce05827334f68cb61#reply-5e89d1e22fcec10052c109ee)

What is the drawback of exposing props globally, it seems it doesn't affect performance or security?

[Serdar Sanri](https://hashnode.com/@ssanri)

[Apr 22, 2020](https://hashnode.com/posts/how-to-make-a-global-component-loader-alert-toast-etc-in-react-native/5d1306582bbe104f674b26a3/comment/5d142f8ce05827334f68cb61#reply-5ea0424a0135fc4176629f5f)

[Kailash Uniyal](https://hashnode.com/@juggernaut23) In a nutshell, Global variables cause (and more) the following issues.

1) Variable naming collisions - If you're working on a team and both yourself and your co-worker use the same variable name on the global scope, the variable defined last will overwrite the initial variable. This obvious can have devastating consequences.

2) Security - Specifically on the web, every user has access to the Window (or global) object. By putting variables on the global scope, you give any user the ability to see or change your variables.

3) Slower - This is arguably negligible, but it still exists. The way JavaScript variable lookups work is the JavaScript engine will do a lookup on the current scope the variable is being looked up in. If it can't find it, it will do a look up on the next parent scope. If it doesn't find it there, it will continue looking upward until it reaches the global object looking for that variable. If all of your variables are located on the global scope, the JavaScript engine will always have to go through every scope in order to finally reach the global scope to find the variable.

[wiki.c2.com](http://wiki.c2.com/?GlobalVariablesAreBad)
