import { render } from 'react-dom';
import {createStore} from "redux";
import rootReducer from "../reducers";
import Auth from './components/Auth';
const store = createStore(rootReducer);
render(
<Provider store={store}>
<BrowserRouter>
<Auth />
</BrowserRouter>
</Provider>,
document.getElementById('root'),
);
import React, {Component} from 'react';
import {connect} from 'react-redux';
class Auth extends Component {
render() {
return (
<Switch>
<Route exact path={this.props.api.signin} render={() => Test}/>
</Switch>
);
}
}
const mapStateToProps = state => ({
api: state.api,
});
export default connect(mapStateToProps)(Auth);
addGroup = () => {
this.setState(prevState => ({ items : [ ...prevState.items, undefined ] }));
};
shouldComponentUpdate( nextProps, nextState ) {
return nextState.items !== this.state.Items;
}
shouldComponentUpdate( nextProps, nextState ) {
return nextState.items !== this.state.Items &&
JSON.stringify(nextState.items.sort()) !== JSON.stringify(this.state.items.sort());
}
в shouldComponentUpdate nextState.items почему-то равно всегда this.state.items
let items = this.state.items;
items.push( undefined );
let items = [ ...this.state.items, undefined ]
state = {
modelSelectors: [{obj1}, {obj2}]
}
renderSelectors = () => {
this.state.model.selectors.map(item => <Select ... />
}
addSelector = () => {
this.setState({ modelSelectors: +1 элемент в массиве })
}
protected $dates = [
'created_at',
];
protected $appends = [
'created_time',
];
public function getCreatedTimeAttribute()
{
return $this->created_at->diffForHumans();
}
render() {
const { _sharedData: { auth_user } } = this.props;
const shouldShowIconMenu = +auth_user === 1;
return (
<AppBar>
{shouldShowIconMenu && (
<IconMenu>
...
</IconMenu>
)}
</AppBar>
);
}
<div id={if (condition) { 'msg' }}>Hello World!</div>
React.createElement("div", { id: if (condition) { 'msg' } }, "Hello World!");
this.props._sharedData.auth_user == 1 ?
<IconMenu
iconButtonElement={
<IconButton style={{height: '64px'}}>
<MoreVertIcon color={white}/>
</IconButton>}
anchorOrigin={{horizontal: 'right', vertical: 'top'}}
targetOrigin={{horizontal: 'right', vertical: 'top'}}>
{ Object.keys(this.props._sharedData.loc.account).map(
(item, i) => (
<MenuItem primaryText={this.props._sharedData.loc.account[item]}/>
))}
</IconMenu>
:null