bluewings / pug-as-jsx-loader

MIT License
188 stars 15 forks source link

throws error on `{props.children}` #47

Closed FicoPrieto closed 4 years ago

FicoPrieto commented 4 years ago

Is there a way to make this work with {props.children} as shown in the docs?

I tried using the following pug layout:

.test-component
  {props.children}

and this error was thrown:

Uncaught Error: Module build failed (from D:/TestProject/node_modules/pug-as-jsx-loader/dist/pug-as-jsx-loader.cjs.js):
Error: D:/TestProject/src/Components/TestComponent/Layout.pug:3:5
    1| .test-component
  > 2|   {__archived_ejbuz7h__}
-----------^

unexpected text "{__ar"
bluewings commented 4 years ago

@FicoPrieto It can be used as follows.

.test-component
  | {children}
import React from 'react';

export default function (props = {}) {
  const { children } = props;
  return (
    <div className="test-component">{children}</div>
  );
}
FicoPrieto commented 4 years ago

Great, that worked! Thanks!