Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not working with React Native #389

Closed
julioxavierr opened this issue Feb 23, 2020 · 13 comments
Closed

Not working with React Native #389

julioxavierr opened this issue Feb 23, 2020 · 13 comments

Comments

@julioxavierr
Copy link
Contributor

julioxavierr commented Feb 23, 2020

I know this release is still in alpha, but I want to already point this out, maybe someone has experienced this before.
I'm testing with 1.3.0-alpha and keep getting the error:

React Native does not have a built-in secure random generator. If you don't need unpredictable IDs, you can use nanoid/non-secure.

@phryneas
Copy link
Member

Hm. We don't really need those to be unpredictable, so we could default to nanoid/non-secure. What do you think @markerikson ?

@markerikson
Copy link
Collaborator

Yayyyy actual alpha feedback! (this is exactly why I've been publishing these alphas - to give us a chance to iterate on redesigning APIs, and hopefully get just enough people trying them to point out any rough spots.)

And yes, let's do that.

@julioxavierr
Copy link
Contributor Author

Awesome, thanks guys!
I'm using this alpha because of the new createAsyncAction, it's just awesome.

@markerikson
Copy link
Collaborator

Great. Any specific feedback on how it feels to actually use the new alpha APIs? Anything that's broken / hard to use / not clear / not sufficiently documented?

@julioxavierr
Copy link
Contributor Author

I wasn't able to test some actions I dispatched inside it, but I don't think that's actually a good practice.
Example: fetching some nested data and I want to dispatch some piece of it for other slice.

@julioxavierr
Copy link
Contributor Author

julioxavierr commented Feb 23, 2020

Still about the error, do you know what's causing it? Maybe I can help to fix it
Couldn't identify libraries for random generation in package.json

@markerikson
Copy link
Collaborator

Yeah, the "error" is due to the fact that we're doing import nanoid from 'nanoid', and it sounds like import nanoid from 'nanoid/non-secure' instead would fix it. The code for this is in the v1.3.0-integration branch: #374

@markerikson
Copy link
Collaborator

markerikson commented Feb 23, 2020

In fact, given how small the source is for this, I'm inclined to say we just inline it ourselves:

https://github.com/ai/nanoid/tree/master/non-secure

I had opted to stick with actually depending on nanoid as a separate package because it looked like the published package had a couple different files to handle browser vs Node environments, but it looks like non-secure is just a tiny function that does some typical Math.random() calls.

Let's just paste that in and drop the dependency.

@phryneas
Copy link
Member

Realisticly though, what hinders us from doing something much simpler?

let id = Date.now(); // if we want to have a starting point, otherwise even 0 might be fine
export function getNextId(){
  return ++id;
};

@phryneas
Copy link
Member

I wasn't able to test some actions I dispatched inside it, but I don't think that's actually a good practice.
Example: fetching some nested data and I want to dispatch some piece of it for other slice.

Could you give a code example of that? Sounds like it should be testable.

@julioxavierr
Copy link
Contributor Author

@phryneas - you're right, double-checked and the problem was on my side

@markerikson
Copy link
Collaborator

Just published https://github.com/reduxjs/redux-toolkit/releases/tag/v1.3.0-alpha.10 , which inlines nanoid/non-secure and should fix this issue. Please try it and let me know.

@julioxavierr
Copy link
Contributor Author

@markerikson - just tried, the change fixes the issue. I'll close it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants