Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use namespace import instead of default import for React #671

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

CruseCtrl
Copy link

@CruseCtrl CruseCtrl commented Nov 3, 2021

I don't have allowSyntheticDefaultImports set in my project, so the typescript compiler is giving me warnings about these imports. This PR will fix the warnings

@CruseCtrl CruseCtrl force-pushed the use-namespace-imports-for-react branch from fa9aedb to 630262c Compare November 3, 2021 17:29
@CruseCtrl CruseCtrl force-pushed the use-namespace-imports-for-react branch from 630262c to 834bbbd Compare November 3, 2021 17:30
@fkhadra
Copy link
Owner

fkhadra commented Feb 14, 2022

Hey, why not enable allowSyntheticDefaultImports in your config?

@CruseCtrl
Copy link
Author

That's what I've been forced to do for now, but it would be nice if it wasn't necessary for all users of this library to have to turn on that compiler flag, and it's a very easy fix to just import it correctly

@@ -1,4 +1,5 @@
import React, { useEffect, useLayoutEffect, useRef } from 'react';
import * as React from 'react';
import { useEffect, useLayoutEffect, useRef } from 'react';

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be

import * as React from 'react';
const { useEffect, useLayout, useRef } = React;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants