How to set Editor to readonly programatically [Help] #2805
-
Hi, I have tried to use the readOnly as below: Is there another way to achieve this? Many thanks |
Beta Was this translation helpful? Give feedback.
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.
Hi @chrishj59! What you did should work essentially.
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?