How to set Editor to readonly programatically [Help] #2805
Unanswered
chrishj59
asked this question in
PrimeReact
Replies: 1 comment
-
Hi @chrishj59! What you did should work essentially. import React, { useState } from 'react';
import { Editor } from 'primereact/editor';
export default function ReadOnlyDemo() {
const [rating, setRating] = useState(0);
return (
<div className="card">
<Editor
value="Always bet on Prime!"
readOnly={rating < 1}
style={{ height: '320px' }}
/>
</div>
);
} Editor also supports read-only mode: https://primereact.org/editor/#readOnly Ensure that prodRating is actually changing as expected. If prodRating is not being updated correctly, the condition prodRating < 1 might always evaluate to the same boolean value. Did you miss this step by any chance? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
I am using the editor component to collect a review comment.
I would like this to be disabled/readonly if the rating component does not have a value.
I have tried to use the readOnly as below:
readOnly={prodRating < 1}
This works when setting the disabled property on InputText.
Disabled does not have any effect on Editor either.
Is there another way to achieve this?
Many thanks
Beta Was this translation helpful? Give feedback.
All reactions