var SomeComp = React.createClass({
...
})
window.SomeComp = SomeComp
...
render(){
...
<SomeComp ... />
...
}
users = {
'Вася' : {
'job': 'Слесарь',
'phone' : 123345
},
'Петя' : {
'job': 'Слесарь',
'phone' : 789901
}
}
jobs = {
'Вася' : { 'job': 'Плотник' },
'Петя' : { 'job': 'Столяр' }
}
Object.assign(obj.users, users)
Object.assign(obj.users, jobs)
Object.assign(obj.users, users, jobs)
obj.users = object_assign(obj.users, users, jobs)
class Parent {
....
handleChildTick(someData){
// обработать данные от потомка
// (указание на конкретного потомка можно вставить в структуру someData)
}
....
render(){
....
<Child ... onTick={this.handleChildTick} />
....
}
}
class Child {
....
someAction(){
....
if(this.props.onTick)
this.props.onTick(someData)
....
}
}
your_data_list = [...]
probabilities_list=[60, 85, 97, 100]
rnd = random.uniform(1, 100)
idx = -1
idx_found = False
while idx < len(probabilities_list) and not idx_found:
idx += 1
idx_found = rnd <= probabilities_list[idx]
your_random = your_data_list[idx]
idx = bisect.bisect_right(probabilities_list, rnd)
numpy.random.choice(your_data_list, size=N, p=prb_list)
class SomeComponent {
...
componentDidMount() {
Store.addListener("DATA_CHANGED", this.handleChanged)
Store.addListener("DATA_LOADED", this.handleLoaded)
}
...
handleLoaded(){
// just force rendering (you can do something smart beforehand though)
this.forceUpdate()
}
...
renderContent(){
// your usual render code
...
}
renderLoading(){
return <Icon type="spinner" spin />
}
render(){
if(Store.isLoading()){
return this.renderLoading()
} else {
return this.renderContent()
}
}
}
class RootComponent {
....
collectData(someData){
// обработать данные от потомка
// (указание на конкретного потомка можно вставить в структуру someData)
}
....
render(){
....
<ColBootstrap ... onStateChange={this.collectData} />
....
}
}
class ColBootstrap {
....
render(){
....
<ClientageBlock... onStateChange={this.props.onStateChange} />
....
}
}
class ClientageBlock {
....
someAction(){
....
if(this.props.onStateChange)
this.props.onStateChange(someData)
....
}
}