code-hike / codehike

Build rich content websites with Markdown and React
https://codehike.org
MIT License
4.74k stars 147 forks source link

Next.js fast refresh doesn't work #212

Closed ghoshnirmalya closed 1 month ago

ghoshnirmalya commented 2 years ago

When I add the following code, fast-refresh breaks:

```python mark=1[22:30]
print("Rendered with Code Hike")

Without the above code, fast-refresh works as expected.

Here's a link to a similar issue.

ghoshnirmalya commented 2 years ago

This issue isn't present in the contentlayer example.

pomber commented 2 years ago

How are you using it with Next.js? What do you mean that it breaks? The page doesn't refresh or the state is not preserved? An example repo would help.

ghoshnirmalya commented 2 years ago

How are you using it with Next.js?

I'm using this example.

What do you mean that it breaks?

When I make a change in the markdown file, the whole Next.js page gets reloaded and then the new changes are visible. The new changes should be visible with hot reload.

Note: This isn't noticeable in the Contentlayer example. In that example, the changes show up without a page reload.

pomber commented 2 years ago

OK, I think I know why this happens. I'll try to fix it soon.

pomber commented 2 years ago

ok, it isn't easy to fix. I'm going to leave it for later.

ghoshnirmalya commented 2 years ago

No problem.

neongreen commented 2 years ago

@pomber can you share any details re/ why you think it happens? I'm hitting this as well.

pomber commented 2 years ago

@pomber can you share any details re/ why you think it happens? I'm hitting this as well.

There are some useState I need to remove from a few Code Hike components, but it isn't a trivial refactor