const reducer = (state = initialState, action) => {
switch (action.type) {
case USER_LOG:
return Object.assign({}, state, {
name: action.payload.name,
rating: [...state.data.rating, action.payload.rating]
})
default: return state;
}
};
const reducer = (state = initialState, action) => {
switch (action.type) {
case USER_LOG:
return {
...state,
name: action.payload.name,
rating: [...state.data.rating, action.payload.rating]
}
default: return state;
}
};
const initialState = {
data: {
name: 'Name',
rating: ["10", "9.1"]
},
};
const lastElement = array[array.length - 1];
const lastElement = [...array].pop();
const lastElement = array.slice(-1).pop();
const lastElement = array.slice(-1)[0];
const lastElement = array.pop();
const handleFiles = () => {
return async handle => {
let result;
result = 'hello';
return result;
};
};
handleFiles()().then(result => console.log(result)).catch(console.log(e));
const handleFiles = async () => {
let result;
result = 'hello';
return result;
};
handleFiles().then(result => console.log(result)).catch(console.log(e));
const mapStateToProps = state => ({
user: state.users.user,
});
return {
...state,
user: state.user.concat({
surname: action.surname,
name: action.name,
patronymic: action.patronymic,
phone: action.phone,
isLoggingIn: action.isLoggingIn
})
};
docRef.get().then((doc) => {
if (doc.exists) {
result = 'Такой номер уже есть';
console.log('Такой номер уже есть');
}else{
db.collection('users').doc(user.phone).set(user);
result = true;
console.log(true);
}
}).catch((error) => {
result = 'Произошла ошибка';
console.log('Произошла ошибка');
});
import {ADD_USER} from './actionTypes';
import {HELLO} from './actionTypes';
import firebase from 'react-native-firebase';
export const addUser = (surname, name, patronymic, phone) => {
return async dispatch => {
let db = firebase.firestore();
let user = {
surname: surname,
name: name,
patronymic: patronymic,
phone: phone,
};
let result = 'начальный';
let docRef = db.collection('users').doc(user.phone);
try {
let doc = await docRef.get()
if (doc.exists) {
result = 'Такой номер уже есть';
console.log('Такой номер уже есть');
} else {
db.collection('users').doc(user.phone).set(user);
result = true;
console.log(true);
}
} catch (e) {
result = 'Произошла ошибка';
console.log('Произошла ошибка');
}
return result;
};
};
let result = this.props.onAddUser(
this.state.controls.surname.value,
this.state.controls.name.value,
this.state.controls.patronymic.value,
this.state.controls.phone.value,
).then(result => console.log(result))
git rm --cached
git rm -rf --cached ios/build
например.сlick(e, item) {
console.log(item);
}
render() {
const { array } = this.state;
const unit = array.map((item, index) => (
<a
key={index}
style={{display:"block"}}
onClick={(e) => this.click(e, item)}
>
Hello, {item}
</a>
));
const allCars = {
bmw: [
{ name: 'x1', ... },
...
],
...
}
render() {
const { mark } = this.props;
const models = allCars[mark];
return (
<div>
{mark && (
<div>
<label>{mark}</label>
{models.map(model => (
<div key={model.name}>
<label>{model.name}</label>
<input
name="model"
value={model.name}
type="checkbox"
onClick={this.props.changemodel}
/>
</div>
))}
<div>
)}
</div>
);
}
changeMark (e) {
const { value } = e.target;
this.setState({
mark: value === 'all' ? [] : [...prevState.mark, value],
model: [],
page: 1,
});
}
}
handleCheckboxCheck(e) {
const { name, value } = e.target;
this.setState(prevState => ({
[name]: _.xor(prevState[name], +value),
}));
}
constructor(props) {
super(props);
this.changeModel = this.changeModel.bind(this);
}
changeModel (e) {
// some actions
}
changeModel = e => {
// some actions
};
beforeEach((done) => {
Todo.remove({}).then(() => {
return Todo.insertMany(todos);
}).then(resolve, reject);
});
() => done()
beforeEach((qwe) => {
Todo.remove({}).then(() => {
return Todo.insertMany(todos);
}).then(() => qwe());
});
var slider = document.querySelectorAll("article");
var circleone = document.getElementById("circle-one");
var circletwo = document.getElementById("circle-two");
var interval;
function Run(){
clearInterval(interval);
interval = setInterval(function() {
for(var i = 0; i < slider.length; i++){
var item = parseInt(slider[i].style.left);
if(item === 0){
item = 100;
slider[i].style.transitionDuration = "0s";
slider[i].style.left = item + "%";
}else{
item-=100;
slider[i].style.transitionDuration = "0.5s";
slider[i].style.left = item + "%";
}
}
}, 4000);
}
Run();
circleone.onclick = function(){
slider[0].style.left = 0 + "%";
slider[1].style.left = 100 + "%";
Run();
}
<select>