Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function InputDemo() {
const myInput = useInput("hello");
return (
<div>
<input>
<p>
Value is <b>{myInput.value}</b>
</p>
</div>
);
}
function UsePreviousDemo() {
const myInput = useInput("hello world");
const previousValue = usePrevious(myInput.value);
return (
<div>
<div>
<input>
</div>
<p>
Current value is <b>{myInput.value}</b>
</p>
<p>
Previous value was <b>{previousValue || "-"}</b>
</p>
</div>
);
}
const Sidebar = ({ children }) => {
const hooks = useContext(HookNamesContext);
const autoCompleteInput = useInput("");
const filteredResults = useFilteredNpmResults(autoCompleteInput.value);
const hooksWithDisplayNames = hooks.map(hookName => `use-${hookName}`);
const listToShow = autoCompleteInput.value.length
? filteredResults
: hooksWithDisplayNames;
return (
{children}
Hooks