<T> = iterable (то есть, что-то перечисляемое, доступное для перебора)
Легенда:
- ✏️ метод изменяет
this. - 🔒 метод не изменяет
this.
Array.prototype.*:
| //https://davidwalsh.name/javascript-loader | |
| var load = (function() { | |
| // Function which returns a function: https://davidwalsh.name/javascript-functions | |
| function _load(tag) { | |
| return function(url) { | |
| // This promise will be used by Promise.all to determine success or failure | |
| return new Promise(function(resolve, reject) { | |
| var element = document.createElement(tag); | |
| var parent = 'body'; |
| // won't work correctly | |
| let counter = 0; | |
| function delay(ms) { | |
| return new Promise((resolve, reject) => { | |
| setTimeout(function() { | |
| console.log(++counter) | |
| resolve() |
| // connect() is a function that injects Redux-related props into your component. | |
| // You can inject data and callbacks that change that data by dispatching actions. | |
| function connect(mapStateToProps, mapDispatchToProps) { | |
| // It lets us inject component as the last step so people can use it as a decorator. | |
| // Generally you don't need to worry about it. | |
| return function (WrappedComponent) { | |
| // It returns a component | |
| return class extends React.Component { | |
| render() { | |
| return ( |
| let id; | |
| beforeEach(done => { | |
| id = mongoose.Types.ObjectId() | |
| done() | |
| }) |
| nock(`${API_ROOT_V1}`) | |
| .log(console.log) | |
| .post('/api/v1/providers/add', {name: 'User', phone: '+7-123-45-67-89'}) | |
| .reply(200, { status: 200, data: '574ad7429a59dcd429adfc32' }) |
| _renderChapter({ name }) { | |
| return ( | |
| <View key={name} style={styles.chapter}> | |
| <Text small style={styles.chapterText}> | |
| {name} | |
| </Text> | |
| <View style={styles.chapterLine} /> | |
| </View> | |
| ); | |
| } |
| // Корневой адрес API: https://mysterious-reef-29460.herokuapp.com/api/v1 | |
| // POST /validate (введены корректные данные: username = 'max', password = '12345' | |
| { | |
| "status": "ok", | |
| "data": { | |
| "id": 1 | |
| } | |
| } |
| JSX. Позволяет нам писать HTML как синтаксис, который преобразуется в объекты lightweightJavaScript. | |
| Виртуальный DOM (Virtual DOM) — JavaScript-представление реального DOM. | |
| React.Component — способ создания нового компонента. | |
| render (method) — описывает, как будет выглядеть пользовательский интерфейс | |
| для конкретного компонента. | |
| ReactDOM.render — выполняет рендер React-компонента на узел (node) DOM. |
| import React from 'react' | |
| import ReactDOM from 'react-dom' | |
| class HelloWorld extends React.Component { | |
| render() { | |
| return ( | |
| <div>Hello World!</div> | |
| ) | |
| } | |
| } | |
| ReactDOM.render(<HelloWorld />, document.getElementById('root')); |