I'm looking for your help to help me understand React better.
I have an idea for a simple app. It’s based on an educational activity I did in a training session once, and I think it’s a good opportunity for me to learn React.
Here’s the premise. You’re given a shuffled deck of cards. Each card has a type of activity on the card and is a certain color based on the type of learning preference it targets. For example one card may say “You use music during breaks”. You go through the card and place all the ones you actively do in your classroom into one pile, and place the ones you don’t in the discard pile. At the end of the activity, you have a clearer picture of what learning preferences you target, and what preferences you don’t. And you get ideas for activities to do in the classroom.
I thought making a digital version of this would work well. The app would present each card to you and ask you if you do that activity. When you’re all done, the cards would be displayed in both piles.
Here’s where I need advice. How would you architect this in React? I assume each card would be a component. I would imagine that I’d have the cards in an array and would iterate through the array, displaying each card. When the card is selected, I’d push it into one of two other arrays, a “does” array and a “does not” array. At the end of the process I’d iterate through both arrays and render the components into one of the two “piles”.
But I’m unsure how to orchestrate all of this. Doing this with jQuery would be pretty simple. But I’d like to know how you React folks would tackle something like this. I'm not really looking for code though. Just some nudges in the right direction.
I'm also not looking to get free consulting from anyone. I won't be selling this app. I'll open source it.
I think in Facebook's React docs, there is an image where they draw a UI (a todo list or something) and then use different colored boxes to break down the interface, could be something like
this is just conceptual, in the code you would just have TodoApp call Input, and the Input module would know about InputTextbox and SubmitButton...
Anyway React is still primarily a view layer, but it sounds like you are modelling your model layer - they can be separate. Maybe begin by drawing the UI - which actual components will be displayed at different times, and how can you compose them.
Then you figure out how to deal with the model/controller, whether using Redux or something else. In my experiment with React and Elixir, I actually pushed the model/controller to the Elixir server, so the React app just rendered a single state tree received through websockets, and actions just caused a message to be sent to the server, which resulted in an updated state tree being pushed out. This worked well because it was a shared interface (chat/brainstorming for a group). I'm working on turning this approach into a library.