'Load JSON data with useMemo

In the following line:

it loads the json data using useMemo

import MOCK_DATA from './MOCK_DATA.json'
const data = useMemo(() => MOCK_DATA, [])

As it's mentioned in ReactTable that It's important that we're using React.useMemo here to ensure that our data isn't recreated on every render.

My question is will the import statement in reactjs be triggered each time the js file is executed (and that makes useMemo necessary)? If yes, is there a source that mentioned that?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source