Skip to content

Latest commit

 

History

History
49 lines (36 loc) · 1.08 KB

README.md

File metadata and controls

49 lines (36 loc) · 1.08 KB

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