GithubHelp home page GithubHelp logo

react-simple-captcha's People

Contributors

masroorejaz 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

Watchers

 avatar

react-simple-captcha's Issues

Not able to change the background color of captcha

I am creating a function-based react component and loading Enginge inside useEffect method.

  useEffect(() => {
    loadCaptchaEnginge(5, "blue");
  }, []);

But, when I tried to change the background color of the captcha it didn't work.

Cannot use import statement outside a module

SyntaxError: Cannot use import statement outside a module

This error happened while generating the page. Any console logs will be displayed in the terminal window.
Source
react-simple-captcha (1:0) @ eval

module.exports = require("react-simple-captcha");

It doesn't support .TSX

I tried to use the plugin on my .tsx but it doesn't support it. The error is "Could not find a declaration file for module 'react-simple-captcha'"

[SOLUTION] How to get it working with Next.js

For those looking for a way to get this working in Next.js or any SSR based environment. Do the following:

Step 1: Create a null reference to the library.

const [ReactCaptcha, setReactCaptcha] = useState(null as any)

Step 2: Dynamically load module using useLayoutEffect

useLayoutEffect(() => {
    async function loadModule() {
      setReactCaptcha(await import('react-simple-captcha'))
    }
    loadModule()
}, [])

Step 3: have a useState() hook for rendering the Captcha Component.

useLayoutEffect(() => {
    if (ReactCaptcha) {
      setRender(true)
    }
}, [ReactCaptcha])

useEffect(() => {
    if (render) {
      setTimeout(() => {
        ReactCaptcha.loadCaptchaEnginge(6, '#07090e', 'rgb(0, 200, 0)', 'lower')
      }, 250)
    }
}, [render])

Step 4: Render Captcha Component only when it's ready to be rendered.

return (
  <div>
    <div className="captcha">
      {render ? <ReactCaptcha.LoadCanvasTemplate /> : null}
    </div>
  </div>
)

remove color style from link

let LoadCanvasTemplate_HTML = "<div><canvas id=\"canv\"></canvas><div><a id=\"reload_href\"  style=\"cursor: pointer; color: blue\">Reload Captcha</a></div></div>";

Link styled inline is hard to override, please leave it for user css
Color blue looks bad on blue background

SyntaxError: Cannot use import statement outside a module

Hello,
I nest using this package it shows me this error

error - .../node_modules/react-simple-captcha/react-simple-captcha.js:1
import React, { Component } from 'react';
^^^^^^

SyntaxError: Cannot use import statement outside a module

Doesn't work in React 18

Tried to load both parser.


Module not found: Error: Can't resolve 'buffer' in 'learn/node_modules/react-html-parser/node_modules/htmlparser2/lib'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
	- add a fallback 'resolve.fallback: { "buffer": require.resolve("buffer/") }'
	- install 'buffer'
If you don't want to include a polyfill, you can use an empty module like this:
	resolve.fallback: { "buffer": false }

Unable write test cases using jest

Unable to run the test cases after importing it into the component getting below error
cannot use import statement outside a module react js

Extract code image / send it in email

I would like the generated code, which is obviously burnt in a picture, send in email.
Is there a way to do that?

So I have set the 'loadCaptchaEngine' and the and I want to send the appearing code in email. I know how to send email in my code, I just want to extract the picture/code somehow.

Could you please tell me how I can acquire that?

Cannot use import statement outside a module

Using react-remix, attempting to run locally I receive this issue:

import { Component } from 'react';
^^^^^^

SyntaxError: Cannot use import statement outside a module
    at Object.compileFunction (node:vm:352:18)
    at wrapSafe (node:internal/modules/cjs/loader:1033:15)
    at Module._compile (node:internal/modules/cjs/loader:1069:27)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:827:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/Users/brooke/Personal Projects/remix-website/build/index.js:113:168)
    at Module._compile (node:internal/modules/cjs/loader:1105:14)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
ERROR: "dev:server" exited with 1.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

This should be solvable by making the package.json contain {"type": "module"} but I'm not sure if that will fix this.

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.