import { useRouteMatch, Link, useParams } from 'react-router-dom';
function UserId() {
let { userName } = useParams();
let userNameСap = userName[0].toUpperCase() + userName.substring(1);
let match = useRouteMatch();
let usersLink = match.url.split('/')[1];
let userNameImg = './img/' + useParams().userName +'.jpg'; // ИМПОРТ В КОМПОНЕНТЕ НЕ ДЕЛАЕТСЯ! КАК БЫТЬ???
return (
<>
<div className="container">
<h1>User: { userNameСap }</h1>
<img src={ userNameImg } alt={ userNameСap }/>
<Link to={ `/${usersLink}` }>Назад</Link>
</div>
</>
);
}
export default UserId;
const arrayLabels = ['India', 'Indonesia', 'Russia', 'China', 'Bangladesh', 'Nepal', 'Bhutan', 'Myanmar', 'Laos', 'Cambodia', 'Vietnam', 'Malaysia'];
const arrayData = [2467, 560, 540, 20, 114, 121, 103, 85, 17, 150, 20, 295];
const arrayBackgroundColor = ['#55E6C1', '#3B3B98', '#F97F51', '#25CCF7', '#EAB543', '#CAD3C8', '#FEA47F', '#1B9CFC', '#F8EFBA', '#58B19F', '#2C3A47', '#B33771'];
const arrayOneMore = ['zzz', 'zzz', 'zzz', 'zzz', 'zzz', 'zzz', 'zzz', 'zzz', 'zzz', 'zzz', 'zzz', 'zzz'];
// etc.
function chartDataSort(arrayLabels, arrayData, ...args) {
console.log(`number of argents: ${args.length}`);
const arrayOfObj = [];
arrayLabels.map((label, i) => {
const el = { labels: label, data: arrayData[i] || 0 };
let argsObj = {};
args.map((arg, a) => {
argsObj[a] = arg[i] || 0;
});
el.args = argsObj;
arrayOfObj.push(el);
});
arrayOfObj.sort((a, b) => parseInt(b.data) > parseInt(a.data));
/* ... */
handlerClick() {
console.log('Link clicked', this);
this.hide();
this.show();
console.log(this.counter++);
}
start() {
this.counter = 1;
this.mylink.addEventListener('click', this.handlerClick.bind(this, this.counter));
}
...
handlerClick() {
console.log('Link clicked', this);
self.hide();
self.show();
}
start() {
window.self = this;
this.mylink.addEventListener('click', this.handlerClick);
}
...