Uncaught TypeError: Illegal invocation
Nobody has claimed this yet.
- Dominant language
- MDX
- Stars
- 175k
- Forks
- 78.6k
- Avg merge
- 7h 19m
- Merged PRs (30d)
- 35
Description
Prerequisites
- I have searched for duplicate or closed issues
- I have validated any HTML to avoid common problems
- I have read the contributing guidelines
Describe the issue
After upgrade 3 to 5 bootstrap version and fully rework modals call, a get error "Uncaught TypeError: Illegal invocation".

I use react, and have everytime in DOM the element like (let's name it Container):
<div id="modalDlg"></div>.
First of all i initialize modal container by:
this.modalElement = new bootstrap.Modal($("#modalDlg"));
In Container i put conditionally by React some modal content like a:
<div className="modal-dialog"><div className="modal-content"><div className="modal-header"></div>Some content</div></div>
and after that try to show modal window like it is described in documentation for bootstrap v5:
this.modalElement.show()
But catch an error:
"Uncaught TypeError: Illegal invocation"
Help me please, spent already a lot of time for that (maybe you should handle errors with more description because it is really hard to debug such common errors)
Reduced test cases
https://codepen.io/diesel9/pen/QWVPmYR
What operating system(s) are you seeing the problem on?
Windows
What browser(s) are you seeing the problem on?
Chrome
What version of Bootstrap are you using?
5.2.3
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the reduced test case at https://codepen.io/diesel9/pen/QWVPmYR and compare its React modal initialization with the Bootstrap 5.2.3 modal documentation. Reproduce the Illegal invocation error in Chrome, then trace whether the issue is in the modal usage or Bootstrap's handling of the supplied element; done means the cause and a reproducible resolution are documented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, react
- Domain
- frontend, web-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100