# Custom Components don't initialize on second page

**URL:** <https://community.thunkable.com/t/custom-components-dont-initialize-on-second-page/2753672>\
**Category:** Issues / Bugs\
**Created:** [December 18, 2023, 1:45am UTC](https://community.thunkable.com/t/custom-components-dont-initialize-on-second-page/2753672 "2023-12-18T01:45:59Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![tthompson41231](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tthompson41231/32/161401_2.png) [@tthompson41231](https://community.thunkable.com/u/tthompson41231)\
**Post date:** [December 18, 2023, 1:45am UTC](https://community.thunkable.com/t/custom-components-dont-initialize-on-second-page/2753672/1 "2023-12-18T01:45:59Z")

</div>

If you’re having issues with custom components, I figured it out. Custom components aren’t always initializing component variables when they are not located on the first page. The workaround I did was to create a function that sets all variables to their initial state.

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [December 18, 2023, 4:08am UTC](https://community.thunkable.com/t/custom-components-dont-initialize-on-second-page/2753672/2 "2023-12-18T04:08:12Z")

</div>

Do you mind giving an example of this?

---

<div class="post-metadata">

**Author:** ![tthompson41231](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tthompson41231/32/161401_2.png) [@tthompson41231](https://community.thunkable.com/u/tthompson41231)\
**Post date:** [December 18, 2023, 12:50pm UTC](https://community.thunkable.com/t/custom-components-dont-initialize-on-second-page/2753672/3 "2023-12-18T12:50:52Z")

</div>

You can also put that if statement inside the function.

 ![example](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/8/0/80cb5090035bf99523d92a1ca925a99f6892ec20.png)

---

<div class="post-metadata">

**Author:** ![ioannis](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/ioannis/32/146956_2.png) [@ioannis](https://community.thunkable.com/u/ioannis)\
**Post date:** [December 18, 2023, 1:31pm UTC](https://community.thunkable.com/t/custom-components-dont-initialize-on-second-page/2753672/4 "2023-12-18T13:31:27Z")

</div>

Hello @tthompson41231 👋  
The issue is that on the variable name, you are using a question mark.  
As it is mentioned [in our docs](https://docs.thunkable.com/blocks/blocks/variables) “Variable names can only contain alphanumeric characters and underscore. Invalid characters may cause your app to crash.”

---

<div class="post-metadata">

**Author:** ![tthompson41231](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tthompson41231/32/161401_2.png) [@tthompson41231](https://community.thunkable.com/u/tthompson41231)\
**Post date:** [December 18, 2023, 2:16pm UTC](https://community.thunkable.com/t/custom-components-dont-initialize-on-second-page/2753672/5 "2023-12-18T14:16:31Z")

</div>

Interesting, I use question marks all the time and have never had an issue. I removed the question marks but this bug still exists. Variables are not being initialized on second page and on.

---

<div class="post-metadata">

**Author:** ![tthompson41231](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tthompson41231/32/161401_2.png) [@tthompson41231](https://community.thunkable.com/u/tthompson41231)\
**Post date:** [December 18, 2023, 2:31pm UTC](https://community.thunkable.com/t/custom-components-dont-initialize-on-second-page/2753672/6 "2023-12-18T14:31:46Z")

</div>

Can you test out this example component on screen 1 and 2? Maybe its just on my end.

Set up as shown below

![Variable Test](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/7/8/780ee3df4e3a76bfad49d760abbbfe68d91a9828.png)

[https://x.thunkable.com/component/65805471e7fa09ebbabfcb8b/](https://x.thunkable.com/component/65805471e7fa09ebbabfcb8b/)

These are the components blocks

 ![Variable Test 2](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/e/0/e0e1f1f07f50f740bb52460c85a757d1c068536d.png)

---

<div class="post-metadata">

**Author:** ![matt\_conroy](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/matt_conroy/32/150843_2.png) [@matt\_conroy](https://community.thunkable.com/u/matt_conroy)\
**Post date:** [February 22, 2024, 6:51pm UTC](https://community.thunkable.com/t/custom-components-dont-initialize-on-second-page/2753672/7 "2024-02-22T18:51:01Z")

</div>

Hi @tthompson41231, our apologies that this message got lost in the shuffle. Yes, I can see where I get the null conditional if this CC is added on any screen other than the first. We’ll take a look and see if this needs to be fixed or what is going on here. Appreciate your patience!

---

<div class="post-metadata">

**Author:** ![ioannis](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/ioannis/32/146956_2.png) [@ioannis](https://community.thunkable.com/u/ioannis)\
**Post date:** [November 8, 2024, 1:33pm UTC](https://community.thunkable.com/t/custom-components-dont-initialize-on-second-page/2753672/8 "2024-11-08T13:33:13Z")

</div>


