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.
Hm. We don't really need those to be unpredictable, so we could default to nanoid/non-secure. What do you think @markerikson ?
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.
Awesome, thanks guys!
I'm using this alpha because of the new createAsyncAction, it's just awesome.
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?
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.
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
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: https://github.com/reduxjs/redux-toolkit/pull/374
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.
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;
};
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.
@phryneas - you're right, double-checked and the problem was on my side
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.
@markerikson - just tried, the change fixes the issue. I'll close it.
Most helpful comment
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
nanoidas a separate package because it looked like the published package had a couple different files to handle browser vs Node environments, but it looks likenon-secureis just a tiny function that does some typicalMath.random()calls.Let's just paste that in and drop the dependency.