<div id="app"></div>
function App() {
const [ dark, setDark ] = React.useState(null);
const updateDark = e => setDark(e.type === 'mouseover' ? e.currentTarget.id : null);
return (
<React.Fragment>
{[ 'left', 'right' ].map(n => (
<div
id={n}
key={n}
onMouseOver={updateDark}
onMouseLeave={updateDark}
className={dark && dark !== n ? 'dark' : ''}
></div>
))}
</React.Fragment>
);
}
ReactDOM.render(<App />, document.getElementById('app'));
render () {
const { projects } = this.props;
const activeProjects = projects.filter(project => project.ProjectStatus === "ACTIVE");
const projectsList = activeProjects.map(project => (
<div key={i} className="focus-projects">
...
</div>
));
return (
...
);
}
this.setState({
activeProjects: this.props.projects.filter(project.ProjectStatus === "ACTIVE"),
});
In software engineering, a software design pattern is a general, reusable solution to a commonly occurring problem within a given context in software design. It is not a finished design that can be transformed directly into source or machine code. It is a description or template for how to solve a problem that can be used in many different situations. Design patterns are formalized best practices that the programmer can use to solve common problems when designing an application or system.
import axios from 'axios';
const posts = {
getPosts(){
return axios
.get('https://jsonplaceholder.typicode.com/p2osts/1')
.then(r => {data: r.data})
.catch(error=> {
handleError(error, 'posts.getPosts()')
return {error}
})
}
}
import axios from 'axios';
const posts = {
getPosts(){
return axios
.get('https://jsonplaceholder.typicode.com/p2osts/1')
.then(r => r.data)
.catch(error=> {
handleError(error, 'posts.getPosts()')
throw err;
})
}
}
this.passw.search(this.reg) == -1 || this.login.search(this.reg) == -1
почему?