Open
Description
I'm currently reviewing React Typescript with Vite. My React version is 18.2.0 and ESLint version 8.2.0.
I've been checking on ways to open a link on a new tab with a button. and found the following to be a valid way of nesting elements to do so:
function LinkNewTab() {
return (
<a target='_blank' rel='noreferrer' href={import.meta.env.VITE_URL}>
<div>
<button>Text</button>
</div>
</a>
);
}
export default LinkNewTab;
The output was working as expected, but running the linter in my terminal returns the following message:
The prop value with an expression type of MetaProperty could not be resolved. Please file an issue ( https://github.com/jsx-eslint/jsx-ast-utils/issues/new ) to get this fixed immediately.
The prop value with an expression type of MetaProperty could not be resolved. Please file an issue ( https://github.com/jsx-eslint/jsx-ast-utils/issues/new ) to get this fixed immediately.
The error message no longer shows up when I modified my approach to simply trigger window.open
upon clicking the button and removing the wrapping anchor and div tags.
function LinkNewTab() {
return (
<button onClick={() => window.open(import.meta.env.VITE_URL, '_blank')}>Text</button>
);
}
export default LinkNewTab;
Metadata
Assignees
Labels
No labels