Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Variable passing issue #50

Open
mark-todd opened this issue Aug 10, 2022 · 1 comment
Open

Variable passing issue #50

mark-todd opened this issue Aug 10, 2022 · 1 comment

Comments

@mark-todd
Copy link

I'm not quite sure how to classify this bug - I've never seen something like it before! React mathquill behaves differently depending on where it receives variables from - see below:

import React, { useState } from 'react';
import { EditableMathField } from 'react-mathquill';

interface IEditableMathQuill {
    start_value: string
}
const inner_start_value = "\\frac{1}{\\sqrt{2}}\\cdot 2";
export const EditableMathQuill = (props: IEditableMathQuill) => {
  
  console.log(props.start_value, inner_start_value);
  const [latex, setLatex] = useState(props.start_value);

  return (
    <div>
      <EditableMathField
        className='mq-editable-field'
        latex={latex}
        onChange={(mathField) => {
          setLatex(mathField.latex());
        }}
      />
      
      <p>{latex}</p>
    </div>
  );
};

Using props.start_value (a variable from outside the file), it fails to render, but using "inner_start_value" it succeeds. The console log returns they both have the same value.

Thanks!

@viktorstrate
Copy link
Owner

Using props.start_value (a variable from outside the file), it fails to render, but using "inner_start_value" it succeeds.

Using the variable where? as the initial value for const [latex, setLatex] useState(...)?

Does it print any error messages when it "fails to render"?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants