Skip to content

How to set Editor to readonly programatically [Help] #2805

Answered by qwadrox
chrishj59 asked this question in PrimeReact
Discussion options

You must be logged in to vote

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?

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by melloware
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
2 participants