wswoodruff / strangeluv-native

react-native port of strangeluv
MIT License
12 stars 4 forks source link

Use fetch and a router #7

Open ssomnoremac opened 7 years ago

ssomnoremac commented 7 years ago

Fetch is central to RN especially with thunks, and though it doesn't make sense to use it with just a counter, you could find some open API to hit for some random data.

As hard as it is to choose a router, no app can get very far without one. Just use the current RN navigation API.

ssomnoremac commented 7 years ago

Ok, I just read the README a bit and you have a router and I see where the "screens" are. This is not a very common pattern as you essentially have 3 places with JSX content: containers, components, and screens. If you further subdivide any of these folders I think you'd end up with a mess. In my app, my containers are my screens as they are the connected components (HOC). My folder structure is this if it helps you -actions -components -containers -images -reducers -services(or whatever)

I'm just worried you'll lose people if you go naming things screens because I haven't seen that term used the way you're using it.

wswoodruff commented 7 years ago

@ssomnoremac Thanks for taking a look! I have a recipe written for strangeluv to add a web request helper utility, it uses axios behind the scenes. Do you think that'd suffice instead of fetch?

So screens was the translation of routes when porting strangeluv over to react-native. I see it as separating out where you should set your screens up, and the containers and components folders in the src-level are meant for app-wide containers or components, like a snackbar or dialog. Overall this is a pretty flat tree structure yeah, I've had to get used to having to make files for action-type, action, reducer, and sometimes selector for each major branch of the redux store tree.

I ended up liking it, and there is a fractal structure of container/component folders inside src/screens/*/components (You can have sub-components with containers/components folders inside here).

That's how it was intended anyway,

wswoodruff commented 7 years ago

Oh, I'm sorry I forgot something: The name screen is coming directly from the terms used by react-navigation, the navigation lib used here

ssomnoremac commented 7 years ago

I'm a minimalist, and think too many folders are often a hinderance to adoption. But it was merely a suggestion. I don't know much about axios, but I don't get how it can be any better than fetch, it's just so simple on react native. You have to use fetch at least for the call, so axios would have to wrap itself around fetch unless you found a native implementation of it.