function init() {
  // In development, we need to open a socket to listen for changes to data
  if (process.env.REACT_STATIC_ENV === 'development') {
    const io = require('socket.io-client')
    const run = async () => {
      try {
        const {
          data: { port },
        } = await axios.get('/__react-static__/getMessagePort')
        const socket = io(`http://localhost:${port}`)
        socket.on('connect', () => {
          // Do nothing
        })
        socket.on('message', ({ type }) => {
          if (type === 'reloadClientData') {
            reloadClientData()
          }
        })
      } catch (err) {
        console.log(
          'React-Static data hot-loader websocket encountered the following error:'
        )
        console.error(err)
      }
    }
    run()
  }

  if (process.env.REACT_STATIC_DISABLE_PRELOAD === 'false') {
    startPreloader()
  }
}
function init() {
  // In development, we need to open a socket to listen for changes to data
  if (process.env.REACT_STATIC_ENV === 'development') {
    const io = require('socket.io-client')
    const run = async () => {
      try {
        const {
          data: { port },
        } = await axios.get('/__react-static__/getMessagePort')
        const socket = io(`http://localhost:${port}`)
        socket.on('connect', () => {
          // Do nothing
        })
        socket.on('message', ({ type }) => {
          if (type === 'reloadClientData') {
            reloadClientData()
          }
        })
      } catch (err) {
        console.log(
          'React-Static data hot-loader websocket encountered the following error:'
        )
        console.error(err)
      }
    }
    run()
  }

  if (process.env.REACT_STATIC_DISABLE_PRELOAD === 'false') {
    startPreloader()
  }
}
function init ( ) { // In development, we need to open a socket to listen for changes to data if ( process . env . REACT_STATIC_ENV === 'development' ) { const io = require ( 'socket.io-client' ) const run = async ( ) => { try { const { data : { port } , } = await axios . get ( '/__react-static__/getMessagePort' ) const socket = io ( ` ${ port } ` ) socket . on ( 'connect' , ( ) => { // Do nothing } ) socket . on ( 'message' , ( { type } ) => { if ( type === 'reloadClientData' ) { reloadClientData ( ) } } ) } catch ( err ) { console . log ( 'React-Static data hot-loader websocket encountered the following error:' ) console . error ( err ) } } run ( ) } if ( process . env . REACT_STATIC_DISABLE_PRELOAD === 'false' ) { startPreloader ( ) } }
When in development, init a socket to listen for data changes When the data changes, we invalidate and reload all of the route data
When in development init a socket to listen for data changes When the data changes we invalidate and reload all of the route data
Initialize the data hot - loader