Giter Club home page Giter Club logo

component-playground's Introduction

Build Status Maintenance Status

component-playground

A component for rendering React Components and ES6 code with editable source and live preview

Component Playground

Installation

npm install component-playground

Set up

In the head of your html document, either add the css files from the demo or from a CDN like:

<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/codemirror/5.0.0/codemirror.min.css"/>
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/codemirror/5.0.0/theme/monokai.min.css"/>

In your JSX, require the component and use it like this:

'use strict';

var React = require('react/addons');
var ReactDOM = require('react-dom');
var Playground = require('component-playground');
var Button = require('./components/button');

var componentExample = require("raw!./examples/component.example");

var Index = React.createClass({
  render() {
    return (
      <div className="component-documentation">
        <Playground codeText={componentExample} scope={{React: React, Button: Button}}/>
      </div>
    );
  }
});

ReactDOM.render(<Index/>, document.getElementById('root'));

Props

codeText

React.PropTypes.string.isRequired

codeText takes a string of JSX markup as its value. While you can just pass it a string, I find it is easier to make a separate file and use Webpack's raw loader to load in the raw source. In the example above I use the .example extension, and an examples folder to organize my samples.

An example file would look like:

<Button style={{background: '#3498db'}}>Hi</Button>

scope

React.PropTypes.object.isRequired

When evaluating the JSX, it needs to be provided a scope object. At the very least, React needs to be provided to the scope, if any custom tags aren't being used. See below:

<Playground codeText={componentExample} scope={{React: React}}/>

Any module/component that is used inside the playground needs to be added to the scope object. See /demo for an example of how this works.

theme

React.PropTypes.string

String specifying which CodeMirror theme to initialize with. Defaults to 'monokai'.

collapsableCode

React.PropTypes.bool

Allows the user to collapse the code block.

<Playground collapsableCode={true} codeText={componentExample} scope={{React: React}}/>

initiallyExpanded

React.PropTypes.bool

Makes collapsable code block initially expanded.

<Playground
  collapsableCode={true}
  initiallyExpanded={true}
  codeText={componentExample}
  scope={{React: React}}/>

docClass

React.PropTypes.node

A component class that will be used to auto-generate docs based on that component's propTypes. See propDescriptionMap below for how to annotate the generate prop docs.

<Playground docClass={MyComponent} codeText={componentExample} scope={{React: React}}/>

propDescriptionMap

React.PropTypes.string

Annotation map for the docClass. The key is the prop to annotate, the value is the description of that prop.

<Playground
  docClass={MyComponent}
  propDescriptionMap={{
    collapsableCode: "Allows the user to collapse the code block"
  }}
  codeText={componentExample}
  scope={{React: React}}/>

es6Console

React.PropTypes.bool

Turns preview into a simple console for testing out ES6 code. Use console.log() in the playground to generate output.

<Playground
  es6Console={true}
  codeText={es6Example} />

noRender

React.PropTypes.bool

Defaults to true. If set to false, allows you bypass the component-playground's component wrapper and render method. You can use this option to write higher order components directly in your example code and use your own Render method. NOTE: This option requires that the React.render method be in your code

var ComponentExample = React.createClass({
  render: function() {
    return (
        <p>Hi</p>
    )
  }
});

React.render(<ComponentExample/>, mountNode);

Comparison to react-live

There are multiple options when it comes to live, editable React component environments. Formidable actually has two first class projects to help you out: component-playground and react-live. Let's briefly look at the libraries, use cases, and factors that might help in deciding which is right for you.

Here's a high-level decision tree:

  • If you want fast and easy setup and integration, then component-playground may be the ticket!
  • If you want a smaller bundle, SSR, and more flexibility, then react-live is for you!

Here are the various factors at play:

  • Build: component-playground uses babel-standalone, react-live uses bublรฉ. (Note: react-live might make transpiler customizable in the future).
  • Bundle size: component-playground has a larger bundle, but uses a more familiar editor setup. react-live is smaller, but more customized editor around prism.
  • Ease vs. flexibility: react-live is more modular/customizable, while component-playground is easier/faster to set up.
  • SSR: component-playground is not server-side renderable, react-live is.
  • Extra features: component-playground supports raw evaluation and pretty-printed output out-of-the-box, while react-live does not.
  • Error handling: component-playground might have more predictable error handling than react-live in some cases (due to react-dom, although this might change with React 16).

Maintenance Status

Archived: This project is no longer maintained by Formidable. We are no longer responding to issues or pull requests unless they relate to security concerns. We encourage interested developers to fork this project and make it their own!

component-playground's People

Contributors

aaronjlech avatar alexkrolick avatar alexlande avatar aweary avatar baer avatar boygirl avatar chrisbolin avatar coopy avatar djkirby avatar dstevensio avatar ebrillhart avatar exogen avatar iamdustan avatar joshgordon avatar kenwheeler avatar kylecesmat avatar mxstbr avatar newswim avatar nogsmpls avatar omerts avatar paulathevalley avatar ryan-roemer avatar tizmagik avatar turadg avatar zslabs avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

component-playground's Issues

Cursor jumps after resize

My team is using component-playground on a documentation site where we allow the user to toggle the playground into fullscreen. After a resize, we are experiencing strange cursor jumps when a right arrow key in a middle of one line jumps straight to the beginning of the next line. Has anyone experienced this before?

We will certainly be able to work around this with a re-render once #87 is merged, but I wonder if it makes sense to fix this from within the library.

Provide react-live recommendation

It would be great to have a pros and cons, use cases section in the README for react-live vs component playground. This ticket can serve as a place to refine ideas about how to actually communicate that.

Build is not passing lint

Repro:

npm run check

See all the lint fail.

src/components/editor.jsx
  12:24  error  'theme' is missing in props validation      react/prop-types
  13:27  error  'readOnly' is missing in props validation   react/prop-types
  19:19  error  'readOnly' is missing in props validation   react/prop-types
  19:42  error  'external' is missing in props validation   react/prop-types
  20:38  error  'codeText' is missing in props validation   react/prop-types
  25:20  error  'readOnly' is missing in props validation   react/prop-types
  25:43  error  'onChange' is missing in props validation   react/prop-types
  26:17  error  'onChange' is missing in props validation   react/prop-types
  31:4   error  Unexpected var, use let or const instead    no-var
  31:65  error  'codeText' is missing in props validation   react/prop-types
  34:29  error  'style' is missing in props validation      react/prop-types
  34:58  error  'className' is missing in props validation  react/prop-types

src/components/es6-preview.jsx
    2:0   error  Unnecessary "use strict" directive              strict
   51:8   error  `pairs` is never modified, use `const` instead  prefer-const
   54:13  error  `key` is never modified, use `const` instead    prefer-const
   95:4   error  "clearTimeout" is not defined                   no-undef
  115:4   error  "clearTimeout" is not defined                   no-undef
  116:21  error  "setTimeout" is not defined                     no-undef
  120:4   error  Unexpected var, use let or const instead        no-var
  125:6   error  Unexpected console statement                    no-console
  125:6   error  "console" is not defined                        no-undef
  129:6   error  Unexpected var, use let or const instead        no-var
  130:11  error  Unexpected var, use let or const instead        no-var
  136:6   error  Unexpected var, use let or const instead        no-var
  137:6   error  Unexpected var, use let or const instead        no-var
  152:17  error  eval can be harmful                             no-eval
  152:58  error  There should be no spaces inside this paren     space-in-parens

src/components/playground.jsx
   2:0   error  Unnecessary "use strict" directive              strict
  68:46  error  "console" is not defined                        no-undef
  69:10  error  "console" is not defined                        no-undef
  70:0   error  Line 70 exceeds the maximum line length of 100  max-len

src/components/preview.jsx
   1:0   error  Unnecessary "use strict" directive              strict
  23:26  error  Strings must use doublequote                    quotes
  24:7   error  Missing semicolon                               semi
  32:6   error  "clearTimeout" is not defined                   no-undef
  39:21  error  'noRender' is missing in props validation       react/prop-types
  49:67  error  'context' is missing in props validation        react/prop-types
  50:80  error  'context' is missing in props validation        react/prop-types
  58:54  error  There should be no spaces inside this paren     space-in-parens
  69:6   error  "clearTimeout" is not defined                   no-undef
  70:23  error  "setTimeout" is not defined                     no-undef
  74:6   error  Unexpected var, use let or const instead        no-var
  78:8   error  Unexpected var, use let or const instead        no-var
  80:13  error  Unexpected var, use let or const instead        no-var
  88:8   error  Unexpected var, use let or const instead        no-var
  89:23  error  'noRender' is missing in props validation       react/prop-types
  90:10  error  Unexpected var, use let or const instead        no-var
  91:12  error  eval can be harmful                             no-eval
  93:0   error  Line 93 exceeds the maximum line length of 100  max-len
  99:10  error  eval can be harmful                             no-eval

demo/app.jsx
   2:0   error  Unnecessary "use strict" directive        strict
   4:0   error  Unexpected var, use let or const instead  no-var
   5:0   error  Unexpected var, use let or const instead  no-var
   6:0   error  Unexpected var, use let or const instead  no-var
  12:0   error  Unexpected var, use let or const instead  no-var
  13:0   error  Unexpected var, use let or const instead  no-var
  15:0   error  Unexpected var, use let or const instead  no-var
  16:0   error  Unexpected var, use let or const instead  no-var
  18:0   error  Unexpected var, use let or const instead  no-var
  20:0   error  Unexpected var, use let or const instead  no-var
  28:18  error  Expected property shorthand               object-shorthand
  28:32  error  Expected property shorthand               object-shorthand
  34:18  error  Expected property shorthand               object-shorthand
  34:32  error  Expected property shorthand               object-shorthand
  41:18  error  Expected property shorthand               object-shorthand
  41:32  error  Expected property shorthand               object-shorthand
  49:18  error  Expected property shorthand               object-shorthand
  49:32  error  Expected property shorthand               object-shorthand
  61:18  error  Expected property shorthand               object-shorthand
  61:32  error  Expected property shorthand               object-shorthand
  68:18  error  Expected property shorthand               object-shorthand
  68:32  error  Expected property shorthand               object-shorthand
  74:26  error  "document" is not defined                 no-undef

โœ– 73 problems (73 errors, 0 warnings)

Getting syntax errors

I tried to add

const componentExample = 'const foo = function* (x) { const y = yield x + 1;  return y + 2; }';

as codeContext. But I have been getting the following syntax error:

SyntaxError: unknown: Unexpected token (11:16) 9 | render() { 10 | return ( > 11 | const foo = function* (x) { const y = yield x + 1; return y + 2; } | ^ 12 | ); 13 | } 14 | }

Not sure what I am doing wrong. I also tried to use raw loader but doesnt seem to load.

CodeMirror number lines

It's possible to pass a config prop of CodeMirror to the <Playground>?, I would like to add the number lines to it.

Promises do not work properly

If you have a log in a promise it will not show up in the output. Here is some example code to recreate this.

function get (url){
  return new Promise(function(resolve, reject){
    resolve("test");
  });
}

function printGetData() {
    get('http://example.com')
        .then(function (data) {
            console.log(data);
        });
}

printGetData();

0.14

Migrate to 0.14

Using removed Babel 5 option

After cloning the repo, "npm install" and "npm run dev" I get the following error:
ERROR in ./demo/app.jsx Module build failed: ReferenceError: [BABEL] /Users/x/Websites/component-playground/demo/app.jsx: Using removed Babel 5 option: base.stage - Check out the corresponding stage-x presets http://babeljs.io/docs/plugins/#presets at Logger.error (/Users/x/Websites/component-playground/node_modules/babel-core/lib/transformation/file/logger.js:39:11) at OptionManager.mergeOptions (/Users/x/Websites/component-playground/node_modules/babel-core/lib/transformation/file/options/option-manager.js:265:20) at OptionManager.init (/Users/x/Websites/component-playground/node_modules/babel-core/lib/transformation/file/options/option-manager.js:465:10) at File.initOptions (/Users/x/Websites/component-playground/node_modules/babel-core/lib/transformation/file/index.js:194:75) at new File (/Users/x/Websites/component-playground/node_modules/babel-core/lib/transformation/file/index.js:123:22) at Pipeline.transform (/Users/x/Websites/component-playground/node_modules/babel-core/lib/transformation/pipeline.js:45:16) at transpile (/Users/x/Websites/component-playground/node_modules/babel-loader/index.js:14:22) at Object.module.exports (/Users/x/Websites/component-playground/node_modules/babel-loader/index.js:88:12) @ multi app

Is this a known issue?

Syntax Errors

This is all I have:

import React from "react";
import ReactDOM from "react-dom";
import Playground from "component-playground";
import R from 'ramda'
import flyd from 'flyd'
import './index.css';

const boilerplate = `
class App extends React.Component {
  render() {
    return (
      <p>Hello World</p>
    )
  }
}

ReactDOM.render(<App/>, mountNode)
`

class Index extends React.Component {
  render() {
    return (
      <Playground
        codeText={boilerplate}
        scope={{React, ReactDOM, R, flyd}}
      />
    );
  }
};

ReactDOM.render(<Index/>, document.getElementById('root'));

And I keep getting these syntax issues:

SyntaxError: unknown: Unexpected token (20:0) 18 | } 19 | > 20 | ReactDOM.render(<App/>, mountNode) | ^ 21 | 22 | ); 23 | }

image

I'm not sure how to get this going...

Error trying to import

I get a strange error when I am trying to import Component Playground in my JS files. Here's the error that I'm seeing in dev tools when I have import Playground from 'component-playground':

with-playground

Here's a repo with a simple example of what I have that illustrates the problem. https://github.com/jrios/playground-webpack

Am I missing something?

Create a hosted demo

I'm pretty sure you've got this planned, so I created an issue to track when online demo is available :-)

Code Mirror dependency using npm

Instead of including code mirror using

<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/codemirror/5.0.0/codemirror.min.js"></script>
 <script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/codemirror/5.0.0/mode/javascript/javascript.min.js"></script>

Is there a way to use component-playground by npm installing code-mirror? Maybe using this component - https://github.com/JedWatson/react-codemirror

Use babel runtime, instead of polyfill

Hello,

Babel doesn't allow loading two different version of babel/polyfill. Therefore, running a project which has this (great) library, using babel-node, or babel/register,(in a different version) causes babel to throw an error. It is also unrecommended by @sebmck (creator of babel), to inlcude a polyfill in a library (see babel/babel#1312 (comment)). Using the babel runtime is the recommended solution.

Decorators not transpiling with legacy plugin in webpack conf and babelrc.

Having some trouble getting decorators to work. Added the plugin to babelrc file then did babelrc true and also just tried copy and pasting options over to webpack dev config.

Now the output js file builds and page loads, but transpiling at runtime still isn't working. I just get the standard Babel 6.x doesnt support because blah message.

Anyone know where I should be configuring the runtime babel?

Playground doesn't render lines past ~450px height

The lines are rendered only after selecting the blank area.

I believe this could be fixed by passing viewportMargin: Infinity as an option (or exposing options to be extended via a prop on Playground).

Uncaught Invariant Violation

I don't get this running, please give me some guidance. I tried last release and v1.0.0. I did "npm install" and then "npm run dev". I always get following errors:

localhost 3000 webpack-dev-server

Did I miss sth?

Demo - Add link to repo

Great work on the demo!

Just missing a link back to this repo -- I think you've earned your github badge for the page ;)

Bug: Publishr config is all wrong + not used on latest publication.

Latest package.json has these dependencies:

  "dependencies": {
    "babel-cli": "^6.26.0",
    "babel-core": "^6.26.0",
    "babel-loader": "^6.4.1",
    "babel-polyfill": "^6.26.0",
    "babel-preset-es2015": "^6.24.1",
    "babel-preset-react": "^6.24.1",
    "babel-preset-stage-0": "^6.24.1",
    "babel-preset-stage-1": "^6.24.1",
    "babel-standalone": "^6.26.0",
    "codemirror": "^5.30.0",
    "prop-types": "^15.6.0",
    "react": "^16.0.0",
    "react-codemirror2": "^2.0.2",
    "react-dom": "^16.0.0",
    "rimraf": "^2.6.2",
    "webpack": "^1.15.0"
  },
  • Of the babel-* packages, under src I only see babel-standalone used.
  • I don't see webpack used under src

Are these extra packages that are typically dev only need somewhere that I missed?

webpack build over 1MB?

before i import it

> webpack  --progress --profile --colors --production

3115ms build modules
11ms seal
18ms optimize
16ms hashing
52ms create chunk assets
5749ms additional chunk assets
1ms optimize chunk assets
1ms optimize assets
17ms emit
Hash: 52be11111c7829c756b7
Version: webpack 1.12.14
Time: 9010ms
  Asset    Size  Chunks             Chunk Names
main.js  *253 kB*       0  [emitted]  main
   [0] multi main 52 bytes {0} [built]
       factory:0ms building:3ms = 3ms
    + 286 hidden modules

after i import it

> webpack  --progress --profile --colors --production

6446ms build modules
18ms seal
22ms optimize
32ms hashing
74ms create chunk assets
22070ms additional chunk assets
1ms optimize chunk assets
1ms optimize assets
86ms emit
Hash: ec8fa799601ba0b5d3a3
Version: webpack 1.12.14
Time: 28784ms
  Asset     Size  Chunks             Chunk Names
main.js  *1.26 MB*       0  [emitted]  main
   [0] multi main 52 bytes {0} [built]
       factory:1ms building:2ms = 3ms
    + 584 hidden modules

Potentially unnecessary usage of ReactDOMServer

I noticed that in the Preview the generated component is being rendered to a string, but the result is never actually used. I'm wondering if this is this on purpose, since ReactDOM/Server further contributes to the bundle size?

https://github.com/FormidableLabs/component-playground/blob/master/src/components/preview.jsx#L81

        ReactDOMServer.renderToString(React.createElement(previewComponent, {}, Comp));
        render(
          React.createElement(previewComponent, {}, Comp),
          mountNode
        );

Improvement: onChange callBack

I wanted to update my own state when the code is updated. This can probably be done with an onChange callback property.
Thanks for the great component.

Deprecate noRender

The noRender prop should be deprecated in favor of wrapped components. This will allow greater flexibility in parent-child relationships and specifically with passing context into a component.

Pre-Build JavaScript File Error

When I import the playground component, I get this error:

WARNING in ./~/component-playground/~/babel-core/browser.js
Critical dependencies:
1:478-485 This seems to be a pre-built javascript file. Though this is possible, it's not recommended. Try to require the original source to get better results.
 @ ./~/component-playground/~/babel-core/browser.js 1:478-485

I'm using WebPack + Babel to compile the demo.

Invariant Violation

Hi there, I seem to be getting an invariant violation and can't get my head around what the problem is. I am using webpack and React Router if that helps.

This is the error:

invariant.js:39 Uncaught Error: Invariant Violation: addComponentAsRefTo(...): Only a ReactOwner can have refs. You might be adding a ref to a component that was not created inside a component's `render` method, or you have multiple copies of React loaded (details: https://fb.me/react-refs-must-have-owner).

Here's how my file is setup:

import React from 'react';
import Playground from 'component-playground';

import Button from './Button';
import DebugInfo from "./debug-info";
var contextExample = require('raw!./context.example');

var ComponentRoute = React.createClass({
    render() {
        return (
            <div>
                <Playground
                  context={{environment: "staging"}}
                  codeText={contextExample}
                  scope={{React: React, DebugInfo: DebugInfo}}/>
            </div>
        );
    }
});

export default ComponentRoute;

React 16

๐Ÿ‘‹ Wooohoo, I'm the first schmuck to ask about React 16!!

Being the latest and greatest, I decided to give updating both react and react-dom to 16.0.0, but am getting a few errors when attempting to compile, such as:

ERROR in ./node_modules/component-playground/node_modules/react-dom/lib/ReactCompositeComponent.js
Module not found: Error: Can't resolve 'react/lib/ReactCurrentOwner' in '/Users/zach/Sites/rhinostyle/node_modules/component-playground/node_modules/react-dom/lib'
ERROR in ./node_modules/component-playground/node_modules/react-dom/lib/traverseAllChildren.js
Module not found: Error: Can't resolve 'react/lib/ReactCurrentOwner' in '/Users/zach/Sites/rhinostyle/node_modules/component-playground/node_modules/react-dom/lib'

This is most likely just due to some of the changes FB mentioned in their release post today, but just wanted to make sure we had a note of it here to help determine LOE to update for compatibility. Thanks as always!

Error install v0.1.2

Trying to install del latest version I get:

> [email protected] postinstall /Users/carlos.villuendas/Developer/atoms/re-autocompleted/node_modules/component-playground
> npm run build-lib


> [email protected] build-lib /Users/carlos.villuendas/Developer/atoms/re-autocompleted/node_modules/component-playground
> npm run clean-lib && babel --stage 0 src -d lib


> [email protected] clean-lib /Users/carlos.villuendas/Developer/atoms/re-autocompleted/node_modules/component-playground
> rimraf lib

src doesn't exist

npm ERR! Darwin 14.5.0
npm ERR! argv "/Users/carlos.villuendas/.nvm/versions/node/v4.0.0/bin/node" "/Users/carlos.villuendas/.nvm/versions/node/v4.0.0/bin/npm" "run" "build-lib"
npm ERR! node v4.0.0
npm ERR! npm  v3.3.5
npm ERR! code ELIFECYCLE
npm ERR! [email protected] build-lib: `npm run clean-lib && babel --stage 0 src -d lib`
npm ERR! Exit status 2
npm ERR! 
npm ERR! Failed at the [email protected] build-lib script 'npm run clean-lib && babel --stage 0 src -d lib'.
npm ERR! This is most likely a problem with the component-playground package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     npm run clean-lib && babel --stage 0 src -d lib
npm ERR! You can get their info via:
npm ERR!     npm owner ls component-playground
npm ERR! There is likely additional logging output above.

Cannot require module

Hi, I was trying to incorporate this into a project I was currently working on called material-ui. I tried to npm install this and then just require it like any other component, but I get a huge list of errors that alot of dependencies are missing from babel-core. Is there another process I need to run before I can use this? Thanks

Better error messages

When a component has an error, it would be nice if it logged it to the console in addition to displaying it in the playground. That way we can see the stack trace

build codemirror in

I'm curious why code mirror needs to be included on the page vs. being a node module of this project.

Phantomjs fails on node6

Running yarn test fails locally & in CI when ran on node6. The errors seem to be stemming from phantomjs.

_processChildContext is not available in React 16+

When trying to render the Dialog component from '@blueprintjs/core' I get the following error:

_processChildContext is not available in React 16+. This likely means you have multiple copies of React and are attempting to nest a React 15 tree inside a React 16 tree using unstable_renderSubtreeIntoContainer, which isn't supported. Try to make sure you have only one copy of React (and ideally, switch to ReactDOM.createPortal).

Server rendering broken

I found today that component-playground can't be server rendered because of the code mirror dependency it's bundled with now. Code mirror is browser-only, so you get navigator is not defined when you try to server render.

The solution for me right now is to only load component-playground in the browser. We could fix the issue here by only loading code mirror in the browser, which I would like a little bit better, personally.

migrate to react-codemirror2

react-codemirror has major outstanding issues and many users including myself suspect this package has been abandoned. I authored react-codemirror2 and plan to actively maintain this as a successor moving forward. I encourage you try the new package in your project. Likewise, feel free to open up any issue should you encounter trouble and I'll be on it. Same with general suggestions/improvements - I'm aiming to build it up collaboratively so if you had any shortcomings with the original package please let me know.

Is React 16 required/can React be a peer dependency?

This package currently marks its React dependency as ^16.0.0. Is that an oversight or does it really not work with 15.6.x? As-is it's introducing a second React instance onto the page and causing ref errors.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.