wix-incubator / react-templates

Light weight templates for react
https://wix.github.io/react-templates
MIT License
2.82k stars 207 forks source link

Issue with styled-components #260

Open Jisay opened 3 years ago

Jisay commented 3 years ago

Hello!

It seems that react-templates does not work with styled-components. I have the following error: Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports. Check the render method of MyComponent.

Here is my code : component.js

import React, { Component } from 'react';
import P from './P';

import template from './index.rt.html';

export default class MyComponent extends Component {
  render() {
    return template();
  }
};

P.js

import styled from 'styled-components';

const P = styled.p`
  color: red;
`;

export default P;

index.rt.html

<rt-import name="P" from="./P" />
<P>blabla</P>

Do you know what's wrong? Thanks!