Open ghost opened 5 years ago
Merci Raph pour la review :-) Pour le moment j'ai bossé en mode "ain't nobody got time for that" mais en sachant où je merdais pour revenir plus tard quand je suis moins noob. Même le theme/style est dégueu. je veux utiliser des vars mais je dois apprendre les themes mui.
Constructor : I had trouble making the context work. Yes I prefer removing it as soon as I make it work without this ugly state declaration. I swear the initial class looked better :-)
The spread in mapRecursive it's purposely but still shitty. I'll make a beautiful version.
Yes all functions are not where they are supposed to, like I said I'll work on the context structure.
setPlayerRef, this is ugly but the audio tag needs some bump(load(),play()) after refreshing src attr from the context when changing song. I could store in the component the previous src value and comparing it like a componentReceiveProps would do. I'll look into your advice.
I wanted a reusable state component, I tried hooks that didn't want to compile with class components. But I'll have a look.
Yesterday I refactored Playlist.js into Layout.js broken into separate classes. It taught me more about class structure. I now incrementally understand the concept of wrapping as well (I use withStyle with MuiThemeProvider and the context) so I can maybe clean it all up easily. I wanna try more TS as well. Check the simple search and the ./todo.txt I added. The search took me 2 hours so bear with me.
One problem I had with the context is the constructor / initial value building, the bad class structure, which forced me into gymnastics (method outside state obj that don't ever read state but args). The best solution would be a topological dependency structure between the described values, now it's a procedure inside the constructor/methods which is prone to errors. Another problem is when I update a prop from an object which is an item of a state prop array(favorite track), I think I'm forced to reassign the same state prop containing the displayed item to trigger the render. I don't know if there is a good way in react to update an item from an array which is a state prop without redrawing the whole list. I didn't check yet how bad the redraw is, maybe even when I type in the search bar the file list updates because of the setState({searchKeyword... I need to master the optimization of the redraw in react before delivering good apps.
the ugly context class is now properly declared and cleaned, supports now several routes and doesn't blink each time the route is changed
In PlaylistContext.js , you are overusing state