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.

Clarifying usage with custom react apps

See original GitHub issue

Hi @herrstucki, thank you for putting this library out there - excited to use it. However, I was a little confused about how to set it up, and ran into some issues.

I was using a clone of the popular react-universally starter kit to start off. Like most starter kits, it has its own custom webpack setup. So, putting together the instructions in the changelog and the documentation, I did the following:

  1. Installed the package and created the catalog. Worked fine, added the commands to package.json and I could access the catalog on localhost:4000. All good here (except maybe that it adds 3.0 beta-6 version instead of the release v3)
yarn add catalog
yarn create catalog
  1. I added the library components via pages:
//index.js
const pages = [
  {
    path: '/',
    title: 'Welcome',
    content: pageLoader(() => import('./WELCOME.md')),
  },
  {
    path: '/elements',
    title: 'Elements',
    content: pageLoader(() => import('./ElementPage.js')),
  },
];

...

//ElementPage.js
import React from 'react';
import ReactDOM from 'react-dom';
import { Page, ReactSpecimen, ColorSpecimen } from 'catalog';
import { Logo, Menu } from '../shared/components/DemoApp/Header'; //<------

export default () => (
  <Page>
    <h2>My Buttons</h2>
    
    <ReactSpecimen span={3}>
      <Logo />
      <Header />
    </ReactSpecimen>

    <ColorSpecimen
      name="Red"
      value="#FF5500"
      span={2}
    />

  </Page>
);

At that point, I get the following error:

./shared/components/DemoApp/Header/index.js
Module parse failed: /Users/anuj/Github/react-universally/shared/components/DemoApp/Header/index.js Unexpected token (18:4)
You may need an appropriate loader to handle this file type.
| function Header() {
|   return (
|     <HeaderWrapper>
|       <Logo />
|       <h1>React, Universally</h1>
 @ ./catalog/ElementPage.js 17:14-60
 @ ./catalog/index.js
 @ multi ./node_modules/catalog/dist/cli/config/polyfills.js ./catalog/index.js

I wasn’t sure how to proceed at this point. I added the catalog/babel to my .babelrc but I am not even sure if it is being used by catalog?

If I try yarn catalog-build, I get the same error as above plus the errors below:

static/1.589a5ece.chunk.js from UglifyJs
Unexpected token: punc ()) [./catalog/ElementPage.js:6,15][static/1.589a5ece.chunk.js:29,19]

static/catalog.f474a272.js from UglifyJs
Unexpected token: punc ()) [./catalog/index.js:9,24][static/catalog.f474a272.js:19569,37]

Without the custom react component, it works well!


FWIW: Here’s a repo for you to quickly reproduce the issue: https://github.com/oyeanuj/react-universally/tree/dev-with-catalog

Any ideas?

Thank you!

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
krystof-kcommented, Apr 5, 2018

Hey there, I have a related question (I guess). I’m trying to setup Catalog with externally loaded create-react-app based React components from another repo, added as a dependency. Do you have any clue how to do that? When running Catalog directly in the create-react-app repo everything works fine, but we would like to separate the catalog to another repo. Thanks!

1reaction
jerstuckicommented, Oct 9, 2017

@oyeanuj I released v3.1.0 which adds support for a config file and also always Babel-transpiles from the app’s root folder instead of just from src/. Let me know if there are any issues!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Clarify React Refs by Examples - Deni Apps
You may find out React Refs is confusing like I did. In this article, we use real examples to explain what Ref is,...
Read more >
What is React.js and how use it to build a custom web ...
React has proven its capabilities when building both Custom Web Applications (just take a look at Netflix, Instagram, PayPal, and many more) and ......
Read more >
Using the Effect Hook - React
Hooks are a new addition in React 16.8. They let you use state and other React features without writing a class. The Effect...
Read more >
javascript - React - syntax confusion to clarify - Stack Overflow
I am very new to REACT and obviously tripping on some basic concepts.. Appreciate your kind help. This is my app.js:
Read more >
React with TypeScript: Best Practices - SitePoint
Always add descriptive comments to your props using the TSDoc notation /** comment */ . · Whether you use types or interfaces for...
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