<Link href="/profile">
<img src="/avatar.png" onClick={window.reload} />
</Link>{
type: Link,
props: {
href: "/profile",
children: [
{
type: "img",
props: {
src: "/avatar.png",
onClick: window.reload
}
}
]
}
}const Link = (props) => (
<a href={props.href}>
{props.children}
</a>
)
const App = (props) => (
<Link href="/profile">
<img src="/avatar.png" onClick={window.reload} />
</Link>
)
ReactDOM.renderToStaticMarkup(<App />)
// => "<a href="/profile"><img src="/avatar.png" /></a>"
ReactDOM.render(<App />, document.body)
// => Also attaches onClick handlerconst Link = (props) => ({
type: "a",
props: {
href: props.href,
children: props.children
}
})
const App = (props) => ({
type: Link,
props: {
url: "/profile",
children: [{
type: "img",
params: {
src: "/avatar.png",
onClick: window.reload
}
}]
}
})
ReactDOM.render({ type: App }, document.body)const Link = (props) => (
<a href={props.url}>
{props.children}
</a>
)
const App = (props) => (
<Link url="/profile">
<img
src="/avatar.png"
onClick={window.reload}
/>
</Link>
)
ReactDOM.render(<App />, document.body)const state = {
user: {
id: 1,
avatar: "/avatar.png"
}
}
const App = (state) => (
<Link href={`/profile/${state.user.id}`}>
<img src={state.avatar} />
</Link>
)
ReactDOM.render(App, state)http://rnplay.org
const App = function (state) {
return (
<View>
<NavigationBar
leftButton={{
title: "Back",
handler: function () { alert('Back!');
}}
title={{ title: "Title" }}
rightButton={{
title: "Forward",
handler: function () { alert('Next!');
}}
/>
</View>
);
}action is a plain object
that describes what happened
state = update(state, { type: 'LIKE_ARTICLE', articleId: 42 })
state = update(state, { type: 'ADD_TODO', text: 'Read about Flux.'})
const query = "{
user(id: 1) {
name,
avatar,
friends(from: 0, to: 10) {
name
}
}
}"const paths = [
'user[1]["name", "avatar"]'
'user[1]["friends"][0..10]["name"]'
]repeat