Since the last Visual Studio Code update, I've got problems with IntelliSense autocompletion. Generally if I want to set a function as a prop (it's the most common use case of this problem) then instead of inserting just function name VS Code is adding ={}
brackets. So how to get rid of this:
const func = () => {}
...
<button
onClick={func={}}
/>
and get something like this:
const func = () => {}
...
<button
onClick={func}
/>
To clarify - no new add-ons were installed. It's happening for js/ts
files when writing in React.
CodePudding user response:
How to fix this
- Open VS code.
- Go to File > Preference > Settings then
- type:
run code
in the settings search bar - Select
Edit in settings.json
to open thesettings.json
file - Add the
"javascript.preferences.jsxAttributeCompletionStyle": "none"
line to yoursettings.json
file
Why we do this:
In the defaultSettings.json
file there is this code snippet:
// Preferred style for JSX attribute completions.
// - auto: Insert `={}` or `=""` after attribute names based on the prop type.
// - braces: Insert `={}` after attribute names.
// - none: Only insert attribute names.
"javascript.preferences.jsxAttributeCompletionStyle": "auto",
therefore, the default setting for jsxAttributeCompletionStyle
is auto
and by setting it to "none"
in your settings.json
file you overwrite that default setting.
CodePudding user response:
As a workaround, we can set JSX Attribute Completion Style
to none
.
https://github.com/microsoft/vscode/issues/171609#issuecomment-1387107873