score:2
Accepted answer
require
is used to import javascript code. you probably want something like:
<img src="/images/profilepic.jpg" align="middle"/>
which would read from your public images folder. looking more closely at your terminal i see you have your images inside the components
folder. usually you want to have some images / other assets folder inside a public directory apart from your javascript components.
webpack will compile all the code into a bundle, and your webserver will expose the public files under the root directory.
see webpack publicpath config options for more info.
Source: stackoverflow.com
Related Query
- Module parse fails for .jpg in <img> for React component?
- Getting Module parse failed: Unexpected token (1:0) error when I try to import css file for a specific component in react
- React native Required Unknown Module for custom native component
- Module parse failed: es6 react component with JSX inside .JS file
- how to use Context for class Component in other module in React js
- How to declare the module type of an react component for flowtype, without breaking the formatter?
- React - conditional render fails trying to display component for the second time
- React Module Parse Fails When Adding Images
- How to get rid of underline for Link component of React Router?
- Typescript react - Could not find a declaration file for module ''react-materialize'. 'path/to/module-name.js' implicitly has an any type
- Multiple path names for a same component in React Router
- React - getting a component from a DOM element for debugging
- How to test style for a React component attribute with Enzyme
- React testing library on change for Material UI Select component
- Figuring out how to mock the window size changing for a react component test
- What is the correct way of adding a dependency to react in your package.json for a react component
- How to use an array as option for react select component
- React & Jest, how to test changing state and checking for another component
- Can a react component have multiple areas for child content?
- onChange event for React child component to update state
- Why do I have to .bind(this) for methods defined in React component class, but not in regular ES6 class
- React unable to import component -- module not found
- The right React Component PropTypes for es6 (Weak) Maps, Sets
- How to specify function parameters for React component callback with TypeScript?
- React shouldComponentUpdate() is called even when props or state for that component did not change
- Design Redux actions and reducers for a React reusable component
- Best practice for an "empty" component - null? empty div? (A valid React element (or null) must be returned)
- React Route Component handle all "/" routes EXCEPT for "/login"
- How to get code completion for typed react component properties?
- How to over-ride an @media css for a material-ui react component
More Query from same tag
- How to use component level sass file in next js
- React app not loading with @mui/styles package
- React.js, pulling data from api and then looping through to display
- How to change ReactJS styles dynamically?
- How to fix Reactjs admin and frontend routing with react-router-dom v6 BrowserRouter insted of Switch
- How to avoid complex hierarchies in reactjs index
- How to incorporate CoreUI to React Rails app?
- Show nested route component in new page
- React - Is there a way to check when page is done loading after route change?
- I would like to make a form component. what is an IntrinsicAttributes?
- Where to put callback function in react-transition-group
- React: Suggestion is not showing in the drop-down
- Can I initialize a useState in a loop?
- Why does tabindex here only work with 0 and not the rest?
- ReactJs App's mapped list of buttons from Json file only have the last value of json array
- How to use React-Router with a model
- else statement does not work when (document.exists) is not true "firestore"
- Fetch data and then render it to dom React
- Could not get BatchBridge, make sure your bundle is packaged correctly
- Is implementing toJSON() method enough to make any class instance serializable?
- React guard change the route but does not show the component
- react custom hook causing infinite loop
- How to disable views button in StaticDatePicker in React MUI v5.2.2?
- React Query doesn't seem to be caching
- react-slick carousel somehow adding link to every image
- App keeps re-rendering when setting state in promise using useState in React
- React createContext and useReducer undefined value error
- Firebase getDownloadURL() is really slow at getting image URLs
- Porting WordPress Gutenberg to a Standalone React Component - CSS Styles Not Appearing
- Next.js text cycling component never updates