Skip to content

akrawchyk/react-use-hardpass

Repository files navigation

react-use-hardpass npm

React hook to use hardpass.

install

npm install react-use-hardpass --save

# or with yarn

yarn add react-use-hardpass

usage

function App() {
  const [hardpassRef, hardpassOutput] = useHardpass();
  const { score, feedback } = hardpassOutput;
  const isStrong = score === 4;

  return (
    <div>
      <input ref={hardpassRef} />
      {feedback && feedback.warning && <p>{feedback.warning}</p>}
      {feedback && feedback.suggestions.length > 0 && (
        <ul>
          {feedback.suggestions.map((suggestion, key) => (
            <li key={key}>{suggestion}</li>
          ))}
        </ul>
      )}
    </div>
  )
}

const rootElement = document.getElementById("root");
ReactDOM.render(<App />, rootElement);

license

MIT © Andrew Krawchyk