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.

Current workaround:

It’s not the best way, but if you want to use css-doodle in React you could try the following:

/* doodle.js */

import React from 'react';
import 'css-doodle';

export default ({ rule = '' }) => (
  <css-doodle>{ rule }</css-doodle>
)

/* example.js */

import Doodle from './doodle';

<Doodle rule={`
  :doodle {
    @grid: 2 / 200px;
    grid-gap: 1px;
  }
  background: @pick(red, pink);
`}/>

Better way:

Just use it directly!

import 'css-doodle';

function App() {
  return (
    <css-doodle>{`
      :doodle {
        @grid: 2 / 200px;
        grid: 1px;
      }
      background: @pick(red, pink);
    `}</css-doodle>
  );
}

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:17
  • Comments:11 (4 by maintainers)

github_iconTop GitHub Comments

7reactions
Mizumakicommented, Aug 24, 2019

@papan01

Does this support tsx?

I don’t know the support means, but I use <css-doodle> in Doodle.tsx, and it works.

First, you need to extend JSX.IntrinsicElements interface.

declare namespace JSX {
  interface IntrinsicElements {
    'css-doodle': {}
  }
}

And then, you can use <css-doodle>. (Unfortunately, it seems that there is no type definition yet.)

import React from 'react';
import 'css-doodle';

const Doodle: React.FunctionComponent = () => {
  // code is referenced from https://alligator.io/css/patterns-css-doodle/
  return (
    <css-doodle>
      {`
      :doodle {
        @grid: 5x8 / 100% 15rem;
      }
      :after {
        content: "@index()"
      }
      background: pink;
      margin: .5rem;
    `}
    </css-doodle>
  );
};

export default Doodle;

hmm. Really nice 🥰

7reactions
simonmartoncommented, Jan 22, 2019

I think a template string helper would be nice too, similar to styled-components. Something like this:

/* doodle.js */

import React from 'react';
import 'css-doodle';

export default ([ rule = '' ]) => () => (
  <css-doodle>{ rule }</css-doodle>
);
/* example.js */

import Doodle from './doodle';

const FancyDoodle = Doodle`
  :doodle {
    @grid: 2 / 200px;
    grid-gap: 1px;
  }
  background: @pick(red, pink);
`;

...

<FancyDoodle />
Read more comments on GitHub >

github_iconTop Results From Across the Web

How to specify a port to run a create-react-app based project?
Under " \node_modules\react-scripts\scripts\start.js" , search for "DEFAULT_PORT" and add the desire port number. E.g : const DEFAULT_PORT = parseInt(process.
Read more >
How to specify a port to run a create-react-app based project
When we create a new react app using the npx create-react-app command, the default port for the app is 3000. We can access...
Read more >
Change the default Port for a create-react-app project
To change the default port for a create-react-app project, update the start command in your package.json file to specify the port, e.g. "PORT=3456 ......
Read more >
ReactJS: Changing Default Port 3000 in create-react-app
The default port used by Express is 3000, the same default port used by ReactJS development server. Consequently, we need to resolve this...
Read more >
A simple way to Change React App default port - Medium
The default port for react app is 3000 so your react app would normally run on localhost:3000 . Sometimes, I'm working on a...
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