Hello everyone, I’ve been looking for the reason this test won’t pass.
I’ve read through several posts here, and I’ve tried placing the ‘preview’ id correctly.
I still fail the test.
Now I have simplified the code more, leaving only 1 state variable (the user’s input into the text area), and removing unnecessary useEffects( as lasjorg had suggested in a feedback post last year). I am basically calling the parsing methods inline , in the returned divs.
i don’t see your simplified code when i click on the link you shared to the code.
I think it is a good idea to simplify as you said. Please share the link to the simplified code as well.
One thought that may be worth trying (keeping in mind that I haven’t tried this project myself) is that instead of having the initial state of textInput set to an empty string you could give it the initial value that is currently in your defaultText variable? Thus skipping one react lifecycle that redraws the component when the state is updated?
Move the default text out of the component, then use the defaultText variable as the initial state for the text input state (i.e. as the useState argument).
Remove all the code related to setting the default text, including the conditional rendering (you will only have one state variable).
You can keep the useMemo but I would just inline that code in the JSX (without useMemo).
Make the textarea a controlled input (set the value to the state variable).
When I do this, it passes all the test and it works using React 19. Additionally, the component is only around 40 lines of code and is much easier to reason about.