eddielee394 / react-native-hindsighttrader

Basic stock market watchlist app built with React Native. Disclaimer: this thing is WIP status on an epic level. Checkout develop branch for latest stuff...
4 stars 7 forks source link

Reducer architecture #21

Open eddielee394 opened 4 years ago

eddielee394 commented 4 years ago

I don't feel like the reducer architecture is structured properly. For example, in the watchlist.reducer file, i believe the state is actually being mutated when some of the actions are being fired.

Also, the way the reducer logic is setup for adding & removing symbols should maybe be refactored. Currently ADD_WATCHLIST_SYMBOL actually adds AND removes a symbol from the symbols array, depending on whether the symbol already exists. Which makes the DELETE_WATCHLIST_SYMBOL kind of pointless. Maybe this should be refactored to TOGGLE_WATCHLIST_SYMBOL.

eddielee394 commented 4 years ago

@RaidNeferius All of the components are using the DDD pattern, so each domain has it's own store. The watchlist performance issues mentioned in #19 i think relate to the reducer logic (specifically how the watchlist.data state is being managed). I did some tests & when watchlist.data is being passed as a prop to any components inside SwipeableList, it's causing extra re-renders. WDYR is saying it's because the props are changing, but the value's are still equal. So I think it's an immutability problem with how i'm updating the global state in the reducer.
Watchlist Store: https://github.com/eddielee394/react-native-hindsighttrader/tree/develop/app/components/Watchlist/store

But I'd like you to take a look at some of the other component store implementations as well so we can discuss refactoring or better approaches. Redux is not very performant, so I'm really considering changing to a different state management library.