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.

Doesn't work with react

See original GitHub issue

My App.tsx’s constructor looks like the following in my react app

constructor() {
    super();
    figlet('Sezzle', 'Standard', function(err, data) {
      if (err) {
          console.log('Something went wrong...');
          console.dir(err);
          return;
      }
      console.log(data);
    });
  }

But the output in the console is

Error: FIGlet header contains invalid values.
    at Function.me.parseFont (eval at ./node_modules/figlet/lib/figlet.js (http://localhost:3000/main.js:969:1), <anonymous>:842:19)
    at eval (eval at ./node_modules/figlet/lib/figlet.js (http://localhost:3000/main.js:969:1), <anonymous>:951:31)
    at <anonymous>

I logged in the node module’s parseFont function and I see that the headerData looks like this: ["<!doctype", "html>"] which is why the opts in the function is not being filled.

Please help.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

7reactions
patorjkcommented, May 30, 2019

For apps that use webpack, I’ve added a directory of importable-fonts, they can be used like this:

import figlet from 'figlet';
import standard from 'figlet/importable-fonts/Standard.js'

figlet.parseFont('Standard', standard);

figlet.text('test', {
    font: 'Standard',
}, function(err, data) {
    console.log(data);
});

It seems to work well for me so far, I’m still doing testing on it so I haven’t publicly documented this (though the importable-fonts are in the latest npm release), but this will most likely be the best way to use the library with React.

2reactions
lis355commented, Feb 25, 2019

I’ve found a solution, but I’m coding in Vue, I think i doesn’t matters

  1. Put a needed front to your public directory arbitrages-frontends-admin c__programming_jdam_arbitrages_frontends_admin - _src_views_caption vue arbitrages-frontends-admin - webstorm 2019-02-25 17 09 21
  2. In app root (when app starts) use figlet.defaults
import figlet from "figlet";
...
figlet.defaults({fontPath: window.location.origin + "/assets/ascii-fonts"});
  1. Then just code! But you can use only asyncronous callback-version
	figlet.text(this.$data.text, {
		font: "ANSI Shadow",
		horizontalLayout: "default",
		verticalLayout: "default"
	}, (error, renderedText) => {
		this.$data.renderedText = renderedText;
	});
Read more comments on GitHub >

github_iconTop Results From Across the Web

Create React App not working - Stack Overflow
In my case, "create-react-app" was not installed. to install run this command npm install -g create-react-app. Once installation successful ...
Read more >
What To Do if create-react-app Doesn't Work
1. npm uninstall -g create-react-app ... This is the npm command to uninstall your global installation of create-react-app . Theoretically, when ...
Read more >
React App Not Working? 4 Quick Debugging Tips - Dave Ceddia
Refresh the page - Manually refresh the page. Hit Cmd + Shift + R (Mac) or Shift + F5 (Windows). The Shift is...
Read more >
Having problems with your React App not loading and ...
Yea, I guess this could be an old problem but I just want to share what helped me in case somebody else is...
Read more >
Troubleshooting | React Navigation
Sometimes it might even be due to a corrupt installation. If clearing cache didn't work, try deleting your node_modules folder and run npm...
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