const arr = [
{
id : 1,
city : "Москва",
title : "ООО Мавзолей",
type : ["носки", "аромат"]
},
{
id : 2,
city : "Татарск",
title : "ООО Татарск Продакс",
type : ["коровы", "ЖБ плиты"]
}
];
const filter = {
city: `Татарск`,
title: ``,
type: `коровы`
};
const data = arr.filter(item => {
const title = filter.title === "" ? item.title : filter.title;
return (item.city === filter.city && item.title === title && item.type.includes(filter.type)) ? item : null;
});
console.log(data);
try
{
throw new ArgumentException();
}
catch(Exception)
{
// any new exception thrown here
}
CodeCleanup();
//action
const plusLike = index => ({
type: "PLUS_LIKE",
payload:index
});
const initialState = {
like: 0
};
//reducer
const reducer = (state=initialState ,action) => {
switch(action.type){
case "PLUS_LIKE":
return {
...state,
like: action.payload
}
default:
return state
}
};
const App = () => {
const likes = useSelector(state => state.propReducer.like);
const dispatch = useDispatch();
return (
<div>
<button onClick={ () => dispatch(plusLike(likes+1))}>Like</button>
{ likes }
</div>
);
}
const allReducers = combineReducers({
propReducer:reducer
});
const store = createStore(allReducers);
ReactDOM.render(<Provider store={store}><App/></Provider>, document.getElementById("root"));
var child = require('child_process').execFile;
var executablePath = "C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe";
child(executablePath, function(err, data) {
if(err){
console.error(err);
return;
}
console.log(data.toString());
});