<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[React Native Initialization Example]]></title><description><![CDATA[<p>I am having trouble getting a basic client.  Can someone post a basic running app with initialization? I get failure when instantiating colyseus (new Colyseus.Client(...))</p>
]]></description><link>http://discuss.colyseus.io/topic/116/react-native-initialization-example</link><generator>RSS for Node</generator><lastBuildDate>Sun, 17 May 2026 09:10:59 GMT</lastBuildDate><atom:link href="http://discuss.colyseus.io/topic/116.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 13 Jul 2018 15:10:18 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to React Native Initialization Example on Wed, 01 Aug 2018 14:10:18 GMT]]></title><description><![CDATA[<p>I am having trouble getting a basic client.  Can someone post a basic running app with initialization? I get failure when instantiating colyseus (new Colyseus.Client(...))</p>
]]></description><link>http://discuss.colyseus.io/post/395</link><guid isPermaLink="true">http://discuss.colyseus.io/post/395</guid><dc:creator><![CDATA[merhawie]]></dc:creator><pubDate>Wed, 01 Aug 2018 14:10:18 GMT</pubDate></item><item><title><![CDATA[Reply to React Native Initialization Example on Invalid Date]]></title><description><![CDATA[<p>Hey <a class="plugin-mentions-user plugin-mentions-a" href="http://discuss.colyseus.io/uid/135">@merhawie</a>, do you mind posting the error you’re having? Stack traces and logs would be helpful to help you out. Cheers</p>
]]></description><link>http://discuss.colyseus.io/post/396</link><guid isPermaLink="true">http://discuss.colyseus.io/post/396</guid><dc:creator><![CDATA[endel]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to React Native Initialization Example on Invalid Date]]></title><description><![CDATA[<p>The text of the error that I get is the following:</p>
<p>undefined is not an object (evaluating 'storage.getItem')</p>
<p>getItem (Storage.js:11:24)<br />
Client (Client.js:22:26)<br />
&lt;unknown&gt; (App.js:25:33)</p>
<p>This last line references code outside of the class definition (but the same thing occurs if initialized in the constructor), the line reads: var client = new Colyseus.Client(endpoint);</p>
<p>Does this help? Do I need to provide a screenshot?</p>
]]></description><link>http://discuss.colyseus.io/post/397</link><guid isPermaLink="true">http://discuss.colyseus.io/post/397</guid><dc:creator><![CDATA[merhawie]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to React Native Initialization Example on Invalid Date]]></title><description><![CDATA[<p>I see <a class="plugin-mentions-user plugin-mentions-a" href="http://discuss.colyseus.io/uid/135">@merhawie</a>, have you followed the caveats for React Native compatibility here? <a href="https://github.com/gamestdio/colyseus.js/#react-native-compatibility" rel="nofollow">https://github.com/gamestdio/colyseus.js/#react-native-compatibility</a></p>
<p>Looks like you're missing this:</p>
<pre><code>import { AsyncStorage } from 'react-native';
window.localStorage = AsyncStorage;
</code></pre>
<p>Cheers</p>
]]></description><link>http://discuss.colyseus.io/post/398</link><guid isPermaLink="true">http://discuss.colyseus.io/post/398</guid><dc:creator><![CDATA[endel]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to React Native Initialization Example on Fri, 13 Jul 2018 23:57:32 GMT]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="http://discuss.colyseus.io/uid/1">@endel</a> - thank you for the quick response! Here is my App.js import stack:</p>
<p>import 'react-native-browser-polyfill';<br />
import React, {Component} from 'react';<br />
import {Platform, StyleSheet, Text, View, AsyncStorage} from 'react-native';<br />
//Necessary libraries for Colyseus<br />
window.localStorage = AsyncStorage;<br />
import Colyseus from &quot;colyseus.js&quot;;</p>
<p>Below is a screenshot of the actual error I am receiving:<br />
<img src="/assets/uploads/files/1531526248391-simulator-screen-shot-iphone-6-2018-07-13-at-16.56.50.png" alt="0_1531526246043_Simulator Screen Shot - iPhone 6 - 2018-07-13 at 16.56.50.png" class="img-responsive img-markdown" /></p>
]]></description><link>http://discuss.colyseus.io/post/399</link><guid isPermaLink="true">http://discuss.colyseus.io/post/399</guid><dc:creator><![CDATA[merhawie]]></dc:creator><pubDate>Fri, 13 Jul 2018 23:57:32 GMT</pubDate></item><item><title><![CDATA[Reply to React Native Initialization Example on Tue, 17 Jul 2018 03:41:01 GMT]]></title><description><![CDATA[<p>Hey <a class="plugin-mentions-user plugin-mentions-a" href="http://discuss.colyseus.io/uid/135">@merhawie</a>, I see, managed to reproduce the issue using react-native <code>0.56.0</code>, is this the version you're using as well?</p>
<p>It seems react-native is importing <code>colyseus.js</code> before assigned <code>AsyncStorage</code> to <code>window</code> (even though the import order is correct), and that is causing the problem. 😢</p>
<p>I suspect that's because Babel 7 moves all imports before any other code execution (like <code>window.localStorage = ...</code>)</p>
<p>I'd appreciate if you could come up with a solution for this! I've just <a href="https://github.com/gamestdio/colyseus.js/issues/36" rel="nofollow">created an issue on GitHub about this</a>.</p>
<p>Cheers, thanks for reporting.</p>
]]></description><link>http://discuss.colyseus.io/post/401</link><guid isPermaLink="true">http://discuss.colyseus.io/post/401</guid><dc:creator><![CDATA[endel]]></dc:creator><pubDate>Tue, 17 Jul 2018 03:41:01 GMT</pubDate></item><item><title><![CDATA[Reply to React Native Initialization Example on Invalid Date]]></title><description><![CDATA[<p>Sorry <a class="plugin-mentions-user plugin-mentions-a" href="http://discuss.colyseus.io/uid/135">@merhawie</a>, that was actually my bad.</p>
<p>I've managed to fix this on version <a href="https://github.com/gamestdio/colyseus.js/releases/tag/0.9.11" rel="nofollow"><code>0.9.11</code> of the client</a>. During some refactoring on the client, I've moved the Storage to a different file and forgot that the storage should not have been assigned upon module loading.</p>
<p>It works fine now!</p>
]]></description><link>http://discuss.colyseus.io/post/405</link><guid isPermaLink="true">http://discuss.colyseus.io/post/405</guid><dc:creator><![CDATA[endel]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to React Native Initialization Example on Sun, 22 Jul 2018 01:57:54 GMT]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="http://discuss.colyseus.io/uid/1">@endel</a> haha ... no problem! I felt bad about not being able to figure out for a few days playing with various babel settings. Thank you for finding the fix</p>
]]></description><link>http://discuss.colyseus.io/post/406</link><guid isPermaLink="true">http://discuss.colyseus.io/post/406</guid><dc:creator><![CDATA[merhawie]]></dc:creator><pubDate>Sun, 22 Jul 2018 01:57:54 GMT</pubDate></item><item><title><![CDATA[Reply to React Native Initialization Example on Invalid Date]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="http://discuss.colyseus.io/uid/1">@endel</a> - following this solution I believe there may be an issue with this.connection not being set before client.join command is run. Consequently - there error I am seeing (once the above was solved in 0.9.11) is &quot;Cannot read property 'send' of undefined&quot; @Client.join - Client.js@35</p>
<p>Note - I am running on localhost based on the &quot;chat room&quot; example.</p>
<p>Has anyone else run into this problem?</p>
]]></description><link>http://discuss.colyseus.io/post/407</link><guid isPermaLink="true">http://discuss.colyseus.io/post/407</guid><dc:creator><![CDATA[merhawie]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to React Native Initialization Example on Invalid Date]]></title><description><![CDATA[<p>Hey <a class="plugin-mentions-user plugin-mentions-a" href="http://discuss.colyseus.io/uid/135">@merhawie</a>,</p>
<p>Are you calling <code>client.join()</code> after the <code>onOpen</code> signal, as described here? <a href="https://github.com/gamestdio/colyseus.js#react-native-compatibility" rel="nofollow">https://github.com/gamestdio/colyseus.js#react-native-compatibility</a></p>
]]></description><link>http://discuss.colyseus.io/post/408</link><guid isPermaLink="true">http://discuss.colyseus.io/post/408</guid><dc:creator><![CDATA[endel]]></dc:creator><pubDate>Invalid Date</pubDate></item></channel></rss>