Given I have an AJAX based search field that reacts on user input, requests search results from a backend via AJAX, shows the results in a dropdown below the search field, allows navigation through the search results via cursor keys and reacts on esc
key presses in an intelligent way.
Since the current Backbone based component is broken in many ways, I'd like to reimplement that search component using React
and maybe Flux
architecture.
During planning it turned out, that my component has at least a number of 10 different states (maybe even more), it has to react to actions
triggered by user inputs, and as well to actions
triggered by asynchronous server responses.
Question1: Should I model all state in a store
instead of a the parent component? That meant, that every user input changes the stores state, for example the :searchQuery
, :searchResults
and my parent view component reacts to that state changes?
Question2: Or should I model all state in the parent component itself and omit a store
, dispatcher
and actions
completely?
Question3: Independently from handling state in a store
or in the parent component itself, it turned out, that the component itself can have at least 10 different states, and there should only be a certain number of transitions allowed. Usually, I'd pull in a statemachine implementation here, model all :states
and allowed :transitions
and execute transitions everytime an action is received by the store
or a callback method is called in the parent component. What is the correct React way
to handle states
and transitions
between these states
in a component?
Question4: Which is the to-go-state-of-the-art Flux
implementation for Javascript? I have seen reflux so far, but I'm not sure, that's my poison.
I am open to all kind of suggestions here.