a(["jquery","get_val"],function(a,b){a(function(){var c=a("html");if(c.hasClass("homestead_page")){var d=a(".section_wrap"),e=".resize_rooms";d.find("section.homestead").each(function(){var c=a(this),d=c.find("nav.rooms"),f=d.find(">a");!function(){function b(){a(window).trigger("resize"+e),c.each(function(){var b=a(this),c=b.find(">span"),d=c.width();b.css("width",""),b.css("width",d+h+"px")})}var c=f.find(">span"),d=parseInt(c.eq(0).css("padding-left"),10),g=parseInt(c.eq(0).css("padding-right"),10),h=d+g;a(window).on("load",a.proxy(setTimeout,null,b,1)),setTimeout(b,1)}(),function(){function c(){var b=a(window).width();i>b&&(b=i),b>j&&(b=j),b-=i,f.css("width",""),f.css("width",Math.floor(b*k/l+g)+"px")}var d=74,g=d+28,h=d+50,i=b("minWidth"),j=b("maxWidth"),k=h-g,l=j-i;a(window).on("resize"+e,c),setTimeout(c,1)}()}),d.find(".columns").each(function(){var b=a(this);!function(){var a=b.attr("data-background");a&&b.css("background-image",'url("'+a+'")')}(),require(["section_block_resize"],function(a){b.each(a)})})}})})}(),function(){function a(){var a=Array.prototype.slice.call(arguments,0);"string"!=typeof a[0]&&a.unshift("pages/homestead_subpage"),window.define.apply(this,a)}a.amd={jQuery:!0},/**
case SET_DISPLAY_NAME: {
return {
...state,
name: window.localStorage.getItem('name') ? window.localStorage.getItem('name') : action.payload,
}
}
class App extends React.Component {
constructor(props) {
super(props)
this.state = {
data: [],
isLoading: false,
}
}
componentDidMount() {
const xhr = new XMLHttpRequest();
xhr.open('GET', 'http://localhost:3000/data.json', true); // замените адрес
xhr.send();
this.setState({ isLoading: true })
xhr.onreadystatechange = () => {
if (xhr.readyState !== 4) {
return false
}
if (xhr.status !== 200) {
console.log(xhr.status + ': ' + xhr.statusText)
} else {
this.setState({
data: JSON.parse(xhr.responseText),
isLoading: false,
})
}
}
}
renderProducts() {
const { data, isLoading } = this.state
if (isLoading) {
return <img src='/i/preloader.gif' alt='загружаю...' /> // рисуем прелоадер
} else {
return data.map(item => {
// я здесь отрисываю все через другой компонент, вы же можете просто рисовать сразу верстку для начала
return <ProductCard key={item.id} name={item.name} price={item.price} quantity={item.quantity} />
})
}
}
render() {
return (
<div className='App'>
<div className='product-list'>
{this.renderProducts()}
</div>
</div>
)
}
}
ts-node ./index.ts
(ts-node), скомпилированных файлов вы при этом даже не увидите. return { ...state, year: action.payload }
это вернет вам {year:2017} и в компоненте уже к нему обращаться нужно вот так {year.year}export const handleFilters = (type, val) => {
return (dispatch, getState) => {
switch (type) {
case "input":
dispatch({
type: FILTER_BY_INPUT,
payload: val
});
case "time":
...
}
}
};