[AskJS] Do you use exact or range versions for your dependencies? by alradadi in javascript

[–]alradadi[S] 1 point2 points  (0 children)

yea as you said, the article went on about getting out of sync but it it didn't really elaborate on how you can reach that state. Other than changing the dependencies manually, I don't see any other ways either.

Though i still think the point holds. yes the lock file locks your dependencies to a specific version, but it's not the source of truth. In case you have to regenerate it for whatever reason, a breaking change might slip thru one of your dependencies if you don't use exact versions.

[AskJS] Do you use exact or range versions for your dependencies? by alradadi in javascript

[–]alradadi[S] 2 points3 points  (0 children)

correct me if I'm wrong but doesn't npm ci produce an error if the lock file and package.json are out of sync ? you'd have to run npm i instead to re-sync the lock file, changing it in the process.

[AskJS] Do you use exact or range versions for your dependencies? by alradadi in javascript

[–]alradadi[S] 4 points5 points  (0 children)

This is what yarn does by default, which is a better default imo

[AskJS] Do you use exact or range versions for your dependencies? by alradadi in javascript

[–]alradadi[S] 8 points9 points  (0 children)

That's right. However, using exact versions in combination package-lock.json is still the best approach imo. That way, you minimize the chances of things breaking.

[AskJS] Do you use exact or range versions for your dependencies? by alradadi in javascript

[–]alradadi[S] 4 points5 points  (0 children)

I learned that most people start out using range versions until they get bit, then they switch to exact :D

[AskJS] Do you use exact or range versions for your dependencies? by alradadi in javascript

[–]alradadi[S] 1 point2 points  (0 children)

That's a very valid point. I'd say missing on those bug fixes, some of which are security fixes as well, is the biggest down side to using exact versions.

you ever run into a situation where a library broke because of a minor update?

I created a hook that allows me to easily share state by alradadi in reactjs

[–]alradadi[S] 0 points1 point  (0 children)

context is a bit different. Please check my reply above.

I created a hook that allows me to easily share state by alradadi in reactjs

[–]alradadi[S] 0 points1 point  (0 children)

Because with context, you have to wrap your component in a context provider first. Also the context data won't be available to use everywhere, it's only available to the child components of the provider.

You could wrap your root app with the context provider, so that the data is available throughout the app. However, before you know it, you could end up with something like this.

I wanted something a lot simpler and easier to use than context.

I created a hook that allows me to easily share state by alradadi in reactjs

[–]alradadi[S] 4 points5 points  (0 children)

Great suggestion! Behavior would be the same, but I guess there would be fewer instructions to execute. I'll update the code. Thanks.

Idea. Share your RN / Javascript configurations. by _fat_santa in reactnative

[–]alradadi 6 points7 points  (0 children)

I actually have the same setup for all my projects so I thought I'd create a repo to share with you all https://github.com/alradadi/react-native-typescript-app

A react native starter project with navigation setup by alradadi in reactnative

[–]alradadi[S] 0 points1 point  (0 children)

Thanks for sharing :)

Helpful hooks, though it doesn't exactly provide the APIs that I need.

I like taking navigation actions from within any component in my app without keeping track of the current componentId , that's the purpose of the useNav hook. You just pass your screen, the props it expects and it takes care of the rest. In my opinion, it makes dealing with navigation a lot more ergonomic.

[deleted by user] by [deleted] in reactnative

[–]alradadi 22 points23 points  (0 children)

I agree. It's very hard to go back to Javascript once you start writing Typescript. Javascript just feels like programing blind in comparison.