Skip to content

Variable passing issue #50

@mark-todd

Description

@mark-todd

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions