codehike icon indicating copy to clipboard operation
codehike copied to clipboard

Next.js fast refresh doesn't work

Open ghoshnirmalya opened this issue 2 years ago • 8 comments

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 avatar Jun 28 '22 20:06 ghoshnirmalya

This issue isn't present in the contentlayer example.

ghoshnirmalya avatar Jun 29 '22 03:06 ghoshnirmalya

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.

pomber avatar Jun 30 '22 08:06 pomber

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.

ghoshnirmalya avatar Jun 30 '22 09:06 ghoshnirmalya

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

pomber avatar Jul 01 '22 17:07 pomber

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

pomber avatar Jul 03 '22 12:07 pomber

No problem.

ghoshnirmalya avatar Jul 03 '22 17:07 ghoshnirmalya

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

neongreen avatar Jul 08 '22 11:07 neongreen

@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

pomber avatar Jul 12 '22 14:07 pomber