JavaScript
5
Вклад в тег
null < 0 // false
null > 0 // false
null == 0 // false
null >= 0 // true
let res = usersData.map(item => {
return (
<div key={item.id}>
<p>{item.fullName}</p>
</div>
)
});
return <div> {res} </div>
const ProtectedRoute = ({isAllowed, redirectTo, ...props}) => {
return isAllowed ?
<Route {...props}/> : <Redirect to={redirectTo}/>
};
const App = () => {
const user = useSelector(state => state.users.user);
return (
<Switch>
<ProtectedRoute
isAllowed={user}
redirectTo="/"
path="/new-artist"
component={NewArtist}
/>
<Route path="/register" component={Register}/>
<Route path="/login" component={Login}/>
<Route component={() => <h2>Not Found.</h2>}/>
</Switch>
);
};
let count = 0;
localStorage.getItem('count') ? count = parseInt(localStorage.getItem('count')) : 0;
// parseInt потому, что в значении storage всегда хранится строка.