-
Notifications
You must be signed in to change notification settings - Fork 64
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
How to properly import in next app #13
Comments
Please show your code with import statement. |
You are using an older version of library from another repo. Please read the instructions carefully, you do not need to download anything manually. |
First I tried the same way shown in the instruction and got the same error above. After this I downloaded the file and still got the same result. |
Do you have any instructions to add this to a next js app |
This library manipulates document, and document is not available until client render. import MouseFollower from "mouse-follower";
import gsap from "gsap";
MouseFollower.registerGSAP(gsap);
export default function MyApp({ Component, pageProps }) {
useEffect(() => {
const cursor = new MouseFollower();
})
return (
<>
<Head>
</Head>
<Component {...pageProps} />
</>
)
} |
This works without any error thank you very much for the tip. |
It's explained in the library documentation.
If it doesn't work because of React try this: |
What's that class you are using? If you need to style something try to do it inside of the div. <div data-cursor-text="MY WORK">
<div className={style.imageContainer}> .. </>
</div> |
This is what I am getting. FalconTechNepal.__.Leading.IT.company.in.Nepal.-.Brave.2022-10-20.12-07-07.mp4And this is the code in the component <section className={style.works}>
<div className={`${style.cardBox} row row-cols-2`}>
{work.map((ourWork, index) => (
<div
key={index}
className={index % 2 === 0 ? `${style.box1}` : `${style.box2}`}>
<div
data-cursor='-color-red -lg'
data-cursor-text='MY WORK'>
<div className={style.imageContainer}>
<Image
src={ourWork}
width={900}
height={1000}
objectFit='cover'
alt=''
/>
</div>
</div>
</div>
))}
</div>
</section> |
This issue is probably related to the fact you are using a |
Is the style initialized correctly? I had to import index.scss of the library from node_modules |
I also imported index.scss in global.scss file |
@sagarkhadka am unable to understand what to import and where to import... |
@gaurdivit In next.js I did following things:
After doing all this you should be able to see mouse follower in your web project. |
hello @sagarkhadka can you explain more about your solution please becuz i did exactly what you said but it doesnt work |
@h3ma209 after you mentioned the issue I tried in new fresh next js project and I also got the same issue as you. The mouse follower is not visible and is showing weird behavior like overflowing the page. Since the MouseFollower is using scss in their source file I tried |
it works thank you very much |
@sagarkhadka can I use it in react js? |
if yes then are the steps same as of next js? |
Syntax error: /Users/divitgaur/Documents/stuff/Personal/WEB/Projects/myown_portfolio/node_modules/mouse-follower/src/scss/index.scss Unknown word (102:11)
this error is showing @sagarkhadka |
In react as well the step is same. I just checked in fresh vite react project it is working fine please check the following steps.
import gsap from 'gsap'
import MouseFollower from 'mouse-follower'
MouseFollower.registerGSAP(gsap)
useEffect(() => {
const cursor = new MouseFollower()
}, []) This should do the thing. |
@sagarkhadka also please how can i put the image behind the title or text when it hovers |
It's working perfectly fine didn't change my app.css to app.scss |
@sagarkhadka please can you answer my question |
@h3ma209 I haven't used this feature previously so it took time to know the issue. When image is shown on hover the mouse follower uses To resize you can do |
ok thank you it did work but also i wanted to the title to change color so its visible like |
Is there a way to make this work with tailwind? |
Hey @joshAntoniuk, what problem are you facing. I think even when using tailwind css, the process should be same as shown here. I tried on fresh next 13.4.4 with tailwind with the same process it is working. If you want to change the color or something I think you can do it using .mf-cursor {
@apply text-emerald-600;
@media screen and (max-width: 900px) {
@apply hidden;
}
} |
I have done 'npm install mouse-follower --save' on my next app. How do I correctly import it. I managed to import somehow in _app.tsx but every time page refresh the line 'const cursor = new MouseFollower();' throws an server error and crasheh the web page. But if I commented it and uncomment it then it works fine. But after this if the page refresh it again shows the same error.
The text was updated successfully, but these errors were encountered: