Skip to content

Instantly share code, notes, and snippets.

@glcheetham
Created May 20, 2016 19:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save glcheetham/e0a16e2231075919458aefa791b8e23b to your computer and use it in GitHub Desktop.
Save glcheetham/e0a16e2231075919458aefa791b8e23b to your computer and use it in GitHub Desktop.
React state with strategy pattern
// Example of a React state. Manage this with Flux, Redux, black magic, etc...
import AccountFields from '../Components/AccountFields'
import SurveyFields from '../Components/SurveyFields'
import Confirmation from '../Components/Confirmation'
let pages = [
{"Title": "Account Fields", "ActiveComponent": React.createFactory(AccountFields) },
{"Title": "Survey Fields", "ActiveComponent": React.createFactory(SurveyFields) },
{"Title": "Confirmation", "ActiveComponent": React.createFactory(Confirmation) }
]
let state = pages[0]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment