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>
);
};
upd из комментария:
const [isActive, updActive] = useState(false);
display = isActive ? 'block' : 'none';
let count = 0;
localStorage.getItem('count') ? count = parseInt(localStorage.getItem('count')) : 0;
// parseInt потому, что в значении storage всегда хранится строка.
div {
height: 100px;
width: 100px;
background: green;
display: flex;
}
div {
height: 100px;
width: 100px;
background: green;
position: relative;
}
span {
position: absolute;
width: 20px;
height: 20px;
background: red;
top: 0;
left: 0;
right: 0;
bottom: 0;
}
<div class="block">
<h3 class="block-title">Math Way</h3>
</div>
.block {
width: 100%;
background: red;
color: #fff;
}
.block-title {
padding-top: 30px;
padding-bottom: 10px;
font-weight: 400;
font-size: 28px;
}
const popupForm = document.querySelector(".popupForm");
popupForm.addEventListener("submit", editProfileInfo);