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

[CODE] Upgrade react to v18.2 #201

Closed
Rllyyy opened this issue Oct 28, 2022 · 2 comments · Fixed by #276
Closed

[CODE] Upgrade react to v18.2 #201

Rllyyy opened this issue Oct 28, 2022 · 2 comments · Fixed by #276
Assignees
Labels
code Code is wrong or could be simplified

Comments

@Rllyyy
Copy link
Owner

Rllyyy commented Oct 28, 2022

No description provided.

@Rllyyy Rllyyy added the code Code is wrong or could be simplified label Oct 28, 2022
@Rllyyy Rllyyy self-assigned this Oct 28, 2022
@Rllyyy
Copy link
Owner Author

Rllyyy commented Jan 24, 2023

Issues:

  • ReactDom.render is deprecated (GapText/GapTextDropdown)
  • Module Progress animation is not triggering with StrictMode
  • MUI: Too many re-renders. The layout is unstable.TextareaAutosize limits the number of renders to prevent an infinite loop. (Question Editor)
  • React-Modal: Cannot register modal instance that's already open (only in StrictMode) -> Remove conditionally rendered modal
  • Upgrade framer-motion from 6.2.4 to latest version and fix @ts-ignore at for AnimatePresence in Modules

@Rllyyy
Copy link
Owner Author

Rllyyy commented Mar 12, 2023

At this point is sank hours/days into trying to get the gapText component to work without ReactDom.render but every solution just comes with a range of new problems (rerenders, unfocused, breaking dom elements).

GapText and GapTextDropdown both use ReactMarkdown to first create the html for the question and then insert inputs or dropdowns into the defined positions with ReactDom.render(). Unfortunately React 18 removes support for this. The previous option allowed to usage of markdown

Option 1:
React Markdown supports the components property. The problem is that on an input change the component rerenders and looses focus of the input. Another problem is the order of the values inside the state. The components prop also must include every possible html element (p, span, h1-h6, td, ...). One option to deal with rerenders is to use uncontrolled components. But in the future this could be a problem because i want to remove the forward ref and control all question type from the question component instead. If there a now controlled (Multiple Choice and Multiple Response) and uncontrolled (Gap Text and Gap Text Dropdown) elements this would be confusing and maybe problematic.

<ReactMarkdown
  {/*...*/}
  components={{
        p: ({ node, ...props }) => (
          <p>
            {/*Function to insert input element*/}
          </p>
        ),
    }}

Option 2:
Create remark or rehype plugIn that converts [] into . But then the value of this input must be saved to a ref.

Option 3:
Use a portal for each gap element. No idea how that would work :(

Option 4:
Attach the values/functions with useEffect or useLayoutEffect

Rllyyy added a commit that referenced this issue Apr 22, 2023
@Rllyyy Rllyyy linked a pull request Apr 26, 2023 that will close this issue
Rllyyy added a commit that referenced this issue Apr 27, 2023
* Upgraded to react 18

* Fixed progress not animating

* Fixed React-Modal: Cannot register modal instance that's already open

* Updated cypress to react 18

* Upgraded framer-motion + removed d3-ease

* Fixed first question being fetched twice

* refactored gap-text and gap-text dropdown
@Rllyyy Rllyyy closed this as completed Apr 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code Code is wrong or could be simplified
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant