Mafinar Rashid Khan
Panacea Systems Limited
@mafinar
i.e f(x) = 2*x + 1, what's f(1) kinda stuff??
...so f(10, 20) becomes <F x={10} y={20} where x,y are props, {} captures JS expressions
class MainPage extends Component {
render() {
return <App>
<NavBar />
<SideBar />
<MainContent />
<Footer />
</App>
}
}
class NavBar extends Component {
render() {
return <Navigation>
<HamburgerMenu onClick={openSideBar} />
<LinkMenu links={[["Home", "/home"], ["Products", "/product"]]} />
<UserBar />
</Navigation>
}
}
Sorta
class Item extends Component {
render() {
return <li>{this.props.title}</li>
}
}
class List extends Component {
render() {
return <ul>
{this.props.list.map(
(elem, idx) =>
<Item key={idx} title={elem.title} />)}
</ul>
}
}
Back to the Board...
class Person {
@observable firstName = "Michel";
@observable lastName = "Weststrate";
@observable nickName;
@computed get fullName() {
return this.firstName + " " + this.lastName;
}
}
const user = new Person();
@observer
class PersonComponent extends Component {
render() {
return <div>
{user.fullName} + ({user.nickName || "-"})
</div>
}
}
setTimeout(() => user.nickName = "mafinar", 5000)
import React, {Component} from 'react'
import {observable} from 'mobx'
import {observer} from 'mobx-react'
@observer
class CounterComponent extends Component {
@observable counter = 0
render() {
return <div>
<div onClick={() => ++this.counter}>(+)</div>
<div onClick={() => this.counter = 0}>{this.counter}</div>
<div onClick={() => --this.counter}>(-)</div>
</div>
}
}