question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Empty Element Renders

See original GitHub issue

Following the directions on your README and this blog, I keep getting an empty element that doesn’t show the svg. Any ideas? My Results

My svg file is proper. webpack.config.js (or at least the one that matters, I have configs for each environment but they webpack-merge with this one):

// webpack config
const webpack = require('webpack');
const path = require('path');

module.exports = function() {
  return {
    context: path.join(__dirname, '..', '..'),
    entry: './src/index.jsx',
    output: {
      path: './build/',
      filename: 'bundle.js',
      sourceMapFilename: 'map',
    },
    module: {
      rules: [
        {
          test: /\.(js|jsx)$/,
          exclude: /node_modules/,
          use: 'babel-loader',
        }, {
          test: /\.svg$/,
          include: /assets/,
          use: ['babel-loader', 'svg-react-loader'],
        }
      ]
    },
    resolve: {
      modules: [
        'node_modules',
      ],
    },
  };
};

chatBubble.jsx:

import React from 'react';
import ReactDOM from 'react-dom';
import bubbleIcon from '../assets/bubble.svg'; // TODO: doesn't show properly yet

const buttonStyle = {
  width: 500,
  height: 500,
  position: 'absolute',
  bottom: 3,
  right: 3
};

const bubbleButton = () => (
  <button style={buttonStyle}>
    <bubbleIcon />
    <span>bubble</span>
  </button>
);

export default bubbleButton;

index.jsx (mainly for HMR):

import React from 'react';
import ReactDOM from 'react-dom';
// AppContainer is a necessary wrapper component for HMR
import { AppContainer } from 'react-hot-loader';
import chatBubble from './chatBubble.jsx';

const render = (Component) => {
  ReactDOM.render(
    <AppContainer>
      <Component/>
    </AppContainer>,
    document.getElementById('root')
  );
};

render(chatBubble);

// Hot Module Replacement API
if (module.hot) {
  module.hot.accept('./chatBubble.jsx', () => {
    render(chatBubble)
  });
}

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
gibsoncommented, May 4, 2017

your problem in import bubbleIcon from '../assets/bubble.svg'; component name))) Please read react docs

Caveat: Always start component names with a capital letter. For example, <div /> represents a DOM tag, but <Welcome /> represents a component and requires Welcome to be in scope.

0reactions
RomainGoncalvescommented, May 9, 2017

Thanks @gibson I had the same issue

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to return an empty jsx element from the render function in ...
Just in case anyone want another approach: Since React v16.2 you can use Fragments allowing to add an empty JSX tag like this:...
Read more >
Fragments - React
A common pattern in React is for a component to return multiple elements. Fragments let you group a list of children without adding...
Read more >
What are React Fragments or the React Empty Tags ... - Medium
This is called the Empty tag in React. This is a shorter syntax for React Fragments.
Read more >
Empty tag syntax: <> | Can I use... Support tables for HTML5 ...
The React framework offers a shorthand syntax for fragment components that appears as an empty tag: <></> . While it is supported in...
Read more >
empty - CSS: Cascading Style Sheets - MDN Web Docs
The :empty CSS pseudo-class represents any element that has no children. Children can be either element nodes or text (including whitespace) ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found