document.querySelector('#id1').querySelector('#id2')
document.querySelector('#id1 #id2')
import React, { Component } from 'react'
export default class App extends Component {
render() {
const data = [
{'name': 'Education', 'number': 33},
{'name': 'Promotion', 'number': 10},
{'name': 'Events', 'number': 55 }
]
let tableTemplate;
function makeColumns(row) {
return <td>{row.name} {row.number}</td>
}
tableTemplate = data.map((row, i) => {
return <tr key={i}>{makeColumns(row)}</tr>
})
return (
<table>
<tbody>
{tableTemplate}
</tbody>
</table>
)
}
}
import React, { Component } from 'react'
export default class App extends Component {
render() {
var data = [
{'name': 'Education', 'number': 33},
{'name': 'Promotion', 'number': 10},
{'name': 'Events', 'number': 55 }
];
var tableTemplate;
function makeColumns(row) {
return <td>{row.name} {row.number}</td>
}
tableTemplate = data.map(function(row, i) {
return <tr key={i}>{makeColumns(row)}</tr>
});
return (
<table>
<tbody>
{tableTemplate}
</tbody>
</table>
)
}
}
<Button onClick={resetUsers.bind(this)} >Gotcha!</Button>
this.handleAlertDismiss = this.handleAlertDismiss.bind(this);
пишемthis.state.resetUsers = this.state.resetUsers.bind(this);
constructor() {
super(...props);
this.handleAlertDismiss = this.handleAlertDismiss.bind(this);
this.state = {
showModal: true,
resetUsers: this.handleAlertDismiss
};
}
const resetable = Component => class extends React.Component {
state = {key: 0};
render() {
return <Component
{...this.props}
reset={() => this.setState({key: this.state.key + 1})}
key={this.state.key}
/>;
}
}
примерconst resetable = Component => class extends React.Component {
render() {
return <Component
{...this.props}
reset={() => this.forceUpdate()}
key={Math.random()}
/>;
}
}
module.exports = function(location, cb) {
if (typeof require.ensure == 'function') {
require.ensure([], (require) => {
cb(null, require('./Reports'))
}, 'reports'); // третий параметр
} else {
cb(null, require('./Reports'));
}
}
class MyD3Component extends Component {
componenDidMount() {
ReactDOM.findDOMNode(this.refs.container) // для d3
}
render() {
return <div ref="container" />
}
}
var src = document.querySelector('[src*="bundle"]').getAttribute("src");
__webpack_public_path__ = src.substr(0, src.lastIndexOf("/") + 1);
this.watchCollection
Код React компонента:
class IstManagerListRowComponent {
}
export default {
controller: IstManagerListRowComponent,
bindings: {
'uid': '='
},
template: `
<div className="table-row">$ctrl.uid </div>
`
}
class IstManagerListRowComponent {
set uid(value) {
this._uid = value;
// do something
}
}
<form onSubmit={this.handleSubmitTest}>
//Мы задаем один и тот же стейт на открытие фрагмента формы и на required,
//соответственно если форма открыта, то и поле необходимо
<Input type="checkbox" onChange={()=>this.setState({check: !this.state.check})}/>
<Input type="text" placeholder="Enter UR Number" required={this.state.check}/>
<ButtonInput type="submit" value="Submit Button"/>
</form>