{"id":18924244,"url":"https://github.com/hellsan631/stress-hooks","last_synced_at":"2026-03-14T01:30:19.818Z","repository":{"id":151915245,"uuid":"308397112","full_name":"hellsan631/stress-hooks","owner":"hellsan631","description":"An app to benchmark React Hooks","archived":false,"fork":false,"pushed_at":"2021-06-17T16:41:59.000Z","size":3127,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-12-31T17:35:28.996Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://www.matthiasjenny.com/stress-hooks/","language":"JavaScript","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hellsan631.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-10-29T17:08:52.000Z","updated_at":"2021-06-17T16:42:02.000Z","dependencies_parsed_at":"2023-05-15T20:15:38.702Z","dependency_job_id":null,"html_url":"https://github.com/hellsan631/stress-hooks","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hellsan631%2Fstress-hooks","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hellsan631%2Fstress-hooks/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hellsan631%2Fstress-hooks/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hellsan631%2Fstress-hooks/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hellsan631","download_url":"https://codeload.github.com/hellsan631/stress-hooks/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239921876,"owners_count":19718842,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-08T11:06:17.100Z","updated_at":"2026-03-14T01:30:19.789Z","avatar_url":"https://github.com/hellsan631.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Stress Testing React Hooks\n\n[Stress Testing React Hooks](https://www.matthiasjenny.com/stress-hooks/) is a benchmark tool for [React Hooks](https://reactjs.org/docs/hooks-intro.html).\n\n## Overview\n\nUsers can benchmark the following six components with a benchmark function of their choice:\n\n### `ClassComponent`\n\n```jsx\nclass ClassComponent extends React.Component {\n  constructor(props) {\n    super(props);\n    const { benchmark, args } = this.props;\n    this.state = { result: benchmark(...args) };\n  }\n\n  render() {\n    return (\n      \u003c\u003e\n        \u003ch2\u003eClassComponent\u003c/h2\u003e\n        \u003cdiv\u003e\n          \u003cp\u003eResult: {this.state.result}\u003c/p\u003e\n          \u003cp\u003eRender #: {this.props.renderNumber}\u003c/p\u003e\n        \u003c/div\u003e\n      \u003c/\u003e\n    );\n  }\n}\n```\n\n### `FunctionalComponent`\n\n```jsx\nfunction FunctionalComponent(props) {\n  const { benchmark, args } = props;\n  const result = benchmark(...args);\n\n  return (\n    \u003c\u003e\n      \u003ch2\u003eFunctionalComponent\u003c/h2\u003e\n      \u003cdiv\u003e\n        \u003cp\u003eResult: {result}\u003c/p\u003e\n        \u003cp\u003eRender #: {props.renderNumber}\u003c/p\u003e\n      \u003c/div\u003e\n    \u003c/\u003e\n  );\n}\n```\n\n### `HooksComponent`\n\n```jsx\nfunction NaiveHooksComponent(props) {\n  const { benchmark, args } = props;\n  const [result] = useState(benchmark(...args));\n  return (\n    \u003c\u003e\n      \u003ch2\u003eHooksComponent\u003c/h2\u003e\n      \u003cdiv\u003e\n        \u003cp\u003eResult: {result}\u003c/p\u003e\n        \u003cp\u003eRender #: {props.renderNumber}\u003c/p\u003e\n      \u003c/div\u003e\n    \u003c/\u003e\n  );\n}\n```\n\n### `MemoHooksComponent`\n\n```jsx\nfunction MemoHooksComponent(props) {\n  const { benchmark, args } = props;\n  const calculatedResult = useMemo(() =\u003e benchmark(...args), props.args);\n  const [result] = useState(calculatedResult);\n  return (\n    \u003c\u003e\n      \u003ch2\u003eMemoHooksComponent\u003c/h2\u003e\n      \u003cdiv\u003e\n        \u003cp\u003eResult: {result}\u003c/p\u003e\n        \u003cp\u003eRender #: {props.renderNumber}\u003c/p\u003e\n      \u003c/div\u003e\n    \u003c/\u003e\n  );\n}\n```\n\n### `FunctionHooksComponent`\n\n```jsx\nfunction FunctionHooksComponent(props) {\n  const { benchmark, args } = props;\n  const [result] = useState(() =\u003e benchmark(...args));\n  return (\n    \u003c\u003e\n      \u003ch2\u003eFunctionHooksComponent\u003c/h2\u003e\n      \u003cdiv\u003e\n        \u003cp\u003eResult: {result}\u003c/p\u003e\n        \u003cp\u003eRender #: {props.renderNumber}\u003c/p\u003e\n      \u003c/div\u003e\n    \u003c/\u003e\n  );\n}\n```\n\n### `RefHooksComponent`\n\n```jsx\nfunction RefHooksComponent(props) {\n  const { benchmark, args } = props;\n  const ref = useRef(null);\n  if (ref.current === null) {\n    ref.current = benchmark(...args);\n  }\n  const [result] = useState(ref.current);\n  return (\n    \u003c\u003e\n      \u003ch2\u003eRefHooksComponent\u003c/h2\u003e\n      \u003cdiv\u003e\n        \u003cp\u003eResult: {result}\u003c/p\u003e\n        \u003cp\u003eRender #: {props.renderNumber}\u003c/p\u003e\n      \u003c/div\u003e\n    \u003c/\u003e\n  );\n}\n```\n\n## [Contributing](./CONTRIBUTING.md)\n\n## [License](./LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhellsan631%2Fstress-hooks","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhellsan631%2Fstress-hooks","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhellsan631%2Fstress-hooks/lists"}