When use <<inputId>> instead of <<id>>

UI Components for React
Post Reply
Posts: 1
Joined: 14 Sep 2022, 14:11

14 Sep 2022, 14:28

i wrote a function that help me to bind view and model. the function is this

const[data, setData] = useState({});

const bind = (e) => {
if(e.target.value !== undefined) {
let value = e.target.value;
setData({...data, [e.target.id]: value});
else if(e.checked !== undefined) {
setData({...data, [e.target.id]: e.target.checked});
alert("Binding fails.")

And to used it. i can dot something like that.
In case of inputText :

<div className="field">
<InputText id="id" value={data.id} onChange={bind} />

In case of Password

<div className='field'>
<Password inputId="password" value={data.password} onChange={bind} />

The challeng for me is to member that depending to the view, the propertie to used.
for instance in case of Password, Calendar, Chips, i do have to use InputId but in case on InputText, InputMask, i do have to use id, otherwise it will not work.
so i is very difficult to work like that. i want to know if there is a consistent property that can be used for all views.


Posts: 3299
Joined: 22 Apr 2013, 15:48

17 Sep 2022, 17:07

It all depends on whether its a wrapped component. The `id` will go on the wrapper so like in Password its wrapped in a "DIV" so the Input is inside the div. So basically consulting the documentation of each component is how you know.
PrimeFaces Developer | PrimeFaces Extensions Developer
GitHub Profile: https://github.com/melloware
PrimeFaces Elite 11.0.3 / PF Extensions 11.0.3
PrimeReact 8.0.0

Post Reply

Return to “PrimeReact”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 1 guest