Photo/style.css
/* block */
.Photo {}
/* element */
.Photo__img {}
/* modifier */
.Photo--large {}
/** | |
* CSS Modules Magic: | |
* styles = { Photo: '[hash]-Photo', ... } | |
*/ | |
import styles from './style' | |
import React from 'react' | |
import cn from 'classnames' | |
const Photo = ({src, alt, isLarge}) => | |
<div {...{ className: cn({ |
/* root */ | |
.Photo {} | |
/* modifier */ | |
.Photo--large {} | |
/* child */ | |
.Photo__caption {} |
Photo/style.css
/* block */
.Photo {}
/* element */
.Photo__img {}
/* modifier */
.Photo--large {}
Required Fields
use deep-freeze
in reducer tests to ensure no mutations
We will build a contrived user registration that will take
new user's name and
a link to a picture they want to use for an avatar
The added users will then display below the form.
This will help us
const DynamicRenderer = React.createClass({ | |
render () { | |
const component = this.props.condition | |
? SomeComponent | |
: SomeOtherComponent | |
// This will NOT work as expected | |
return <component /> | |
} | |
}) |
import style from './style' | |
import React, { PropTypes } from 'react' | |
import CSSModules from 'react-css-modules' | |
import createJob from 'JobFactory' | |
import listing from './components/org.JobListing' | |
import heading from './components/org.JobHeading' | |
import details from './components/org.JobDetails' | |
import card from './components/org.JobCard' | |
const DEFAULT_RENDER_TYPE = 'listing' |
render () { | |
const { data, renderAs } = this.props | |
const types = { | |
listing: JobListing, | |
heading: JobHeading, | |
card: JobCard | |
} | |
const component = types[renderAs] | |
const $component = types[renderAs] |