Skip to content

Issue with Custom Input Component in React MDX #2553

Answered by remcohaszing
hakimasyrofi asked this question in Q&A
Discussion options

You must be logged in to vote

Your issue is more of a React issue than an MDX issue. You’re defining the FillInTheBlank component inside your useEffect. That means as far as React is concerned, every time the dependency array useEffect is triggered, the FillInTheBlank component is a new component, unrelated to the previous one.

Your useEffect() should not depend on answers, while abiding to React’s rules of hooks. As long as answers is in the dependency array, or ESLint complains about it, the approach is wrong.

To get a better mental model, I recommend you start by removing useMdxComponents. Then pass the components prop to <Content /> instead while rendering. It looks like your goal is to provide data from this comp…

Replies: 1 comment 7 replies

Comment options

You must be logged in to vote
7 replies
@hakimasyrofi
Comment options

@wooorm
Comment options

@wooorm
Comment options

@remcohaszing
Comment options

Answer selected by hakimasyrofi
@hakimasyrofi
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants