I’m getting mixed messages about which method to use to create a react component. The To-Do tutorial used the extended method. The tutorial at React.js, and nearly every other code example I’ve found, uses React.createClass. I managed to muddle through the official React tutorial, transcribing everything to the ‘new’ way, but there are some core concepts that are not explained very well / not working very well.
For example, I’m having a problem with state. I used the constructor trick to establish state in my component. . But when I handle a click event, and update the state variable with setState, printing this.state.myvar to the console at various points in my code actually returns different results. This is highly confusing.
Also, I’m trying to render subcomponents of a complex dynamic form based on selections from the initial part of the form. In Blaze, this was trivial using session variables like this:
`{{#if period_is_year}}
{{> monthofyear_selector}}
{{> dayofmonth_selector}}
{{/if}}
{{#if period_is_month}}
{{> dayofmonth_selector}}
{{/if}}
{{#if period_is_week}}
{{> dayofweek_selector}}
{{/if}}`
But for the life of me I can’t figure out how to conditionally - and dynamically - show or hide nested react components. This is so frustrating. There are methods in the createClass examples that don’t seem to exist related to mounting and unmounting components, and I can’t find their analog using the extend Component way. Any help is appreciated. Thanks.
-Jerimiah