Home > AI > Frontend > ReactJS >

Using the Public Folder

In the index.html, you can use this %PUBLIC_URL%

<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />

In the javascript code, you can use this process.env.PUBLIC_URL

render() {
  // Note: this is an escape hatch and should be used sparingly!
  // Normally we recommend using `import` for getting asset URLs
  // as described in “Adding Images and Fonts” above this section.
  return <img src={process.env.PUBLIC_URL + '/img/logo.png'} />;
}

Leave a Reply