Hello,
first I want to say, that I really enjoy Primefaces and also the new PrimeReact. Really great work you're doing here.
I have a slight problem with the InputText component that I can't get around. Problem is as follows:
I want to dynamically change classnames on the InputText when there is an error. Everything works fine (setting the variable classnames and passing it to the component) but the InputText is not re-rendered correctly. The effects of the added css classes don't show up directly, but only, when the state of the InputText changes (for example when you enter text into the field).
Is this a bug or am I missing something?
Problem with InputText
AFAIK, it should be reflected without state change as well. Can you create an example with primereact quickstart example
Author,Speaker
https://twitter.com/sudheerjonna
Github: https://github.com/sudheerj
Website http://sudheerjonna.com/
___________________
Sudheer Jonna
https://twitter.com/sudheerjonna
Github: https://github.com/sudheerj
Website http://sudheerjonna.com/
___________________
Sudheer Jonna
-
- Prime
- Posts: 18616
- Joined: 05 Jan 2009, 00:21
- Location: Cybertron
- Contact:
Could you please share code so we can review?
I found the problem myself in the meantime.
It is inside this block in the InputText.js:
Because in my case I wanted to change the className on an input with empty value to realise a required-fields-check, the component was not re-rendered because this.state.filled was equal to nextState.filled AND the value was still empty / unset.
I worked around this by overwriting the component and changing this block slightly. It now looks like this:
Just added && this.props.className === nextProps.className to the if-clause and now it works for me.
It is inside this block in the InputText.js:
Code: Select all
{
key: 'shouldComponentUpdate',
value: function shouldComponentUpdate(nextProps, nextState) {
if (this.state.filled === nextState.filled && !this.inputProps.value) {
return false;
}
return true;
}
}
I worked around this by overwriting the component and changing this block slightly. It now looks like this:
Code: Select all
{
key: 'shouldComponentUpdate',
value: function shouldComponentUpdate(nextProps, nextState) {
if (this.state.filled === nextState.filled && this.props.className === nextProps.className && !this.inputProps.value) {
return false;
}
return true;
}
}
-
- Prime
- Posts: 18616
- Joined: 05 Jan 2009, 00:21
- Location: Cybertron
- Contact:
Thank you, being reviewed by our team.
-
- Posts: 5281
- Joined: 29 Jun 2013, 12:38
Please try it with PrimeReact 1.0.0-beta 5 or 6 version.
Github Profile: https://github.com/mertsincan
-
- Posts: 5281
- Joined: 29 Jun 2013, 12:38
Glad to hear, thanks for the update!
Github Profile: https://github.com/mertsincan
-
- Information
-
Who is online
Users browsing this forum: No registered users and 10 guests