Mark Gerryl Mirandilla
Mark Gerryl Mirandilla

Reputation: 823

Captcha auto-change on input

I'm working on a form with captcha using reactjs and antdesign, My problem is when I type on other fields, the captcha code change.

Hope you understand me..

Thanks

codesandbox

<FormItem>
    <Input
    prefix={<Icon type="key" style={{ color: "rgba(0,0,0,.25)" }} />}
    type="captcha"
    placeholder="captcha"
    addonAfter={<Captcha />}
    />
</FormItem>

Upvotes: 1

Views: 201

Answers (1)

Arman Charan
Arman Charan

Reputation: 5797

In ReactJS: re-rendering can be disabled via shouldComponentUpdate(), by returning false.

See below for a practical example.

See this fork of your CodeSandbox for a working solution.

// Captcha.
class Captcha extends Component {

  // Render.
  render = () => (
    <div className="Captcha">
      <NumberList />
    </div>
  )

  // Should Component Update.
  shouldComponentUpdate = () => false

}

Upvotes: 1

Related Questions