How to detect object hot reload in React development mode
Asked Answered
P

0

8

I want to subscribe or somehow detect the imported file change in React application. This feature is required for development mode only.

For example, this code that imports SVG (I imagined how it could be, but actually any other way is accepted)

import myIcon from './myicon.svg';

function IconSet()
{
    webpack.hot.reload.detector(myIcon).on('change', function(oldMyIcon, newMyIcon)
    {
        // Here I can get new myIcon object and process this by myself
        // ...
    });
}

Is there any way to make this?

Thanks!

Prince answered 12/8, 2021 at 6:12 Comment(1)
Have you managed to solve this issue?Payola

© 2022 - 2024 — McMap. All rights reserved.