Menu acts like static about its labels

UI Components for React
Post Reply
numankayali
Posts: 6
Joined: 08 Dec 2016, 09:29

12 Nov 2017, 17:32

Hello. I have a page works in 2 languages. I have a Menu element on this page. when i switch the language, all of my labels are re-rendered accordig to new language except menu. Although its model change it does not reflect the new language. My code:

import T from 'i18n-react';

//my menu model. when i change the locale i can see that content is changing too in debug.
let items = [
{ label: T.translate("component.home"), command: () => {this.props.history.push('/');} },
{ label: T.translate("component.about"), command: () => {this.props.history.push('/about');} }
];

//i am switching the language from here
<Dropdown value={sessionStorage.getItem('locale')} options={languages} onChange={this.handleLocaleChange()}
handleLocaleChange(e) {
if (e.value ==='tr') {
T.setTexts(require('./language/tr.json'));
sessionStorage.setItem('locale', 'tr');
} else if (e.value ==='en') {
T.setTexts(require('./language/en.json'));
sessionStorage.setItem('locale', 'en');
}
this.forceUpdate();
}

//My link object. It switches and shows the label correctly when language changes!
<Link to="/about" onClick={() => this.props.handlePageChange()}>
{T.translate("component.about")}
</Link>

//My menu and its button. Its only visible when width < 480
//It doesn change the labels. It acts like static.
<Button className="responsiveButton" icon="fa fa-list" onClick={(event) => this.menu.toggle(event)}/>
<Menu model={items} popup={true} ref={el => this.menu = el}/>

kaho29
Posts: 18
Joined: 18 Aug 2017, 10:57

13 Nov 2017, 13:04

Could this be related to what I described here?

viewtopic.php?f=57&t=53045&sid=c735f428 ... caf34067a3

mert.sincan
Posts: 5281
Joined: 29 Jun 2013, 12:38

16 Nov 2017, 13:22

Could you please provide a plunker for us to replicate?
https://plnkr.co/edit/uHHN7wKskRgpHszbPZtj?p=info

kaho29
Posts: 18
Joined: 18 Aug 2017, 10:57

17 Nov 2017, 15:32

I think you can reproduce this behaviour with my plunker I provided over here.

viewtopic.php?f=57&t=53045&sid=61ccb2a3 ... 4719e34c4a

Just replace one of the labels in the "switch"-function and you can see that not only the disabled state is not re-rendered correctly, but also a change in labels.

numankayali
Posts: 6
Joined: 08 Dec 2016, 09:29

19 Nov 2017, 11:26

well, this is my first plunk so i hope i did it right.
my problem is that; when i update the state, button label changes but menu not!
thanks.

https://plnkr.co/edit/YmtooVj0tKLI1AQovvVE?p=info

merve7
Posts: 861
Joined: 12 Sep 2017, 10:44

23 Nov 2017, 15:03

Thanks for plunker. We fixed for next version(PrimeReact 1.2.1)

Post Reply

Return to “PrimeReact”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 6 guests