ueno-llc/create-ueno-app

Issue after creating gatsby project

Closed this issue · 6 comments

I run yarn create ueno-app gatsby gatsby-www and yarn dev. On localhost:8000 I got

Error: React.Children.only expected to receive a single React element child.

Why the overwrite for the gatsby link is not:

import * as React from 'react';
import { Link as GatsbyLink } from 'gatsby';

export const Link = ({ children, ...props }: any) => (
  <GatsbyLink {...props}>
    {children}
  </GatsbyLink>
);

So here is the thing, this is how Link works in NextJS.

https://nextjs.org/docs#with-link-1

To keep consistency (and not having to have different source files) I made this Link component file that lets us use the same syntax in Gatsby and CRA.

Do you have any other idea to make this work?

Humm, so what about, in Button.tsx we keep import { Link } from 'components/link/Link';, even though we don't resolve this component yet and when we run yarn create ueno-app... we do something like:

https://github.com/ueno-llc/create-ueno-app/blob/master/lib/index.js#L53-L61

if (appType === 'cra') {
  // pseudo-code
  copyFolderFromTo('specific/cra/Link', 'src/Link');
}

if (appType === 'next') {
  // pseudo-code
  copyFolderFromTo('specific/next/Link', 'src/Link');
}

I already do this in when the installation is done with create-ueno-app

fs.copyFileSync(path.join(path.resolve(__dirname), '..', 'overwrites', appType, 'Link.tsx'), path.join(projectPath, 'src', 'components', 'link', 'Link.tsx'));

Hehe I am not sure, It was kind of a placeholder, if the other thing fails. I wasn't really sure what to do with this problem.

However, I have successfully released working versions for

  • gatsby
  • cra
  • next

And tested

  • yarn dev
  • yarn build
  • yarn start

in all of them

So, now we have a 100% stable create-ueno-app for all app types, even though I am not really satisfied with how we are handling <Link />.

But the more I think about it, the more I like <Link><a>something</a></Link> as an abstraction, but it is an overhead for many people I think

Okay got it. Is it working if the overwrites don't work?