如何在React Native中做更好的路由和应用程序结构?(How to do better routing and app structure in React Native?)
我是一名Java Android开发人员,最近一直在尝试使用React Native。 我一直在研究的东西类似于Android Java代码的导航。
首先,我想要使用SplashScreen。 然后检查用户是否已登录,然后将用户带入应用程序或登录屏幕。
现在,要实现这一点,我需要知道用户是否已登录。我该怎么做? 我不想在index.js中维护全局变量,也不希望index.js成为中央路由系统。 我可以存储一个标志,表明用户已经登录,以及登录用户的访问令牌是什么?
我能够在本机Java代码中很好地可视化,但没有弄清楚如何在React Native中做。
I'm a Java Android developer and been experimenting with React Native lately. What I've been looking into is something similar to the navigation as that of Android Java code.
First, I want to get to SplashScreen. Then check if the user is logged inor not, then take the user into the app or to the login screen.
Now, to achieve this, I need to know if the user is logged in. How do I do that? I don't want to maintain global variables in index.js nor do I want index.js to be the central routing system. Can I store somewhere a flag that says that the user is already logged in, and what's the access-token of the logged in user?
I'm able to visualize this well in native Java code, but failing to figure out how to do in React Native.
原文:https://stackoverflow.com/questions/42423792
最满意答案
Jake,虽然跟踪JIT应该与Crypto库配合得很好,你能尝试用NDK吗? 据我所知,即使在JIT之后,NDK的性能提升仍然很重要。 (大约10-50x)
Jake, although the tracing JIT should work well with Crypto library, can you try doing this with the NDK? From what I've heard, even after the JIT, the performance improvement on the NDK is significant. (Of the order of 10-50x)
相关问答
更多-
这很复杂,但我会尽力解释。 我想我会从Java开始。 我的讨论面向Java 6,我不确定Java 7中发生了什么变化。 Java的内置加密可以通过Java加密扩展(JCE)获得。 该扩展包括两部分,即应用程序API和服务提供者API。 应用程序API是您与之交互的部分。 您可以使用各种加密类的getInstance()工厂方法。 对于普通程序员来说,服务提供者方面更令人困惑。 他们不关心密码是如何实现的,他们只是想要一些可行的东西。 但引擎盖下有一些加密提供程序类来完成实际的工作。 如果您查看getInst ...
-
可以在Android中使用Bouncy Castle加密API吗?(Can the Bouncy Castle cryptography API be used in Android?)[2021-12-16]
是的,事实上,它已经部分包含在内(请参阅http://code.google.com/p/android/issues/detail?id=3280 )。 要获得完整功能,请使用Spongy Castle 。 Yes, in fact, it is already partly included (see http://code.google.com/p/android/issues/detail?id=3280). To get the full functionality, use Spongy Cas ... -
PGP密钥服务器和Bouncy Castle OpenPGP API Java(PGP Key Server and Bouncy Castle OpenPGP API Java)[2021-10-17]
我不知道Bouncy Castle支持密钥服务器通信,但不会考虑这个问题。 用于密钥服务器通信的最广泛传播的协议是HKP ,基于HTTP构建。 将协议实现为客户端实际上并不需要任何大型库,对于基本操作,一些简单的HTTP请求就足够了。 例如, 规范提案列出了以下请求 : 搜索包含字符串“dshaw”的所有密钥: http://keys.example.com:11371/pks/lookup?search=dshaw&op=index 获取密钥0x99242560(32位密钥ID): http://key ... -
AES没有任何弱密钥,所以一个简单的随机生成应该没问题。 // SecureRandom is expensive to initialize (takes several milliseconds) – // consider keeping the instance around if you are generating many keys. SecureRandom random = new SecureRandom(); byte[] keyBytes = new byte[16]; random ...
-
你可能想要Spongy Castle - 我用Bouncy Castle专门针对Android制作的重新包装。 Spongy Castle完全取代了随附Android的Bouncy Castle加密库的残缺版本。 有一些小改动可以在Android上运行: 所有包名都已从org.bouncycastle。*移到org.spongycastle。* - 所以没有类加载器冲突 Java Security API提供程序名称现在是SC而不是BC “Spongy Castle救了我的屁股。” - 来自一个快乐用户的反 ...
-
我测试了下面的代码 - 没有有弹性的城堡 - 并且完美: import android.util.Base64; import java.io.IOException; import java.io.UnsupportedEncodingException; import java.security.GeneralSecurityException; import java.security.InvalidAlgorithmParameterException; import java.security. ...
-
如何使用Bouncy Castle从SHA256哈希生成密钥?(How to generate a key from a SHA256 hash using Bouncy Castle?)[2022-11-03]
在我的情况下,我想使用SecretKeySpec。 以下是一个例子。 SecretKeySpec finalKey = new SecretKeySpec(retval, "RAW"); In my case I wanted to use SecretKeySpec. The following is an example. SecretKeySpec finalKey = new SecretKeySpec(retval, "RAW"); -
我可以在Android上使用Bouncy Castle Keystore.UBER吗?(Can I use Bouncy Castle Keystore.UBER on Android?)[2021-12-26]
是的,可以使用,获取实例: KeyStore.getInstance("UBER", "SC"); 在普通的java代码中,它应该是“BC”(BouncyCastle)提供程序,但是在Android上使用SpongyCastle,所以我们需要在这里放置“SC”。 Yes, It can be used, get instance by: KeyStore.getInstance("UBER", "SC"); In normal java code it should be "BC" (BouncyCas ... -
Jake,虽然跟踪JIT应该与Crypto库配合得很好,你能尝试用NDK吗? 据我所知,即使在JIT之后,NDK的性能提升仍然很重要。 (大约10-50x) Jake, although the tracing JIT should work well with Crypto library, can you try doing this with the NDK? From what I've heard, even after the JIT, the performance improvement o ...
-
如何在Java Keystore中存储Bouncy Castle PGP密钥?(How can I store a Bouncy Castle PGP key in a Java Keystore?)[2024-04-19]
我想将PGP密钥存储在现有的密钥库中。 我已经阅读了Stackoverflow的几个回复,暗示它是可能的,但没有关于如何做出明确答案。 那么我可以将PGP密钥存储在现有的密钥库中吗? Java密钥库不支持OpenPGP密钥。 OpenPGP是另一个与X.509不兼容的标准。 Bouncy Castle的PGP课程不实施密钥或证书。 它确实有JcaPGPKeyPair,它可以包装一个PrivateKey / PublicKey实例。 所以我可以在JCE中创建密钥,然后使用JcaPGPKeyPair将JCE密钥 ...