Rules of hooks
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 25/100
- Issue type
- Feature
- Clarity
- Needs clarification
- Activity status
- Stale
- Tech stack
- react
- Domain
- frontend
Research direction
Start with the React rules-of-hooks documentation linked in the issue and compare it with the current ESLint-on-generated-JavaScript workaround. The issue does not name files, tests, or an entry point, so the implementation scope and completion criteria would need to be established before work begins.
Written by the indexing model from the issue text.
Description
Have there been any plans or proposals to implement the “rules of hooks” into ReasonReact?
(ReactJS docs on the topic for context).
A common pitfall with hooks is that they have a lot of rules you have to follow to avoid breaking your app. Since ReasonReact is using hooks as the recommended way to handle state now, would it be possible to integrate these rules directly into the language?
ReactJS is actually ahead of us in this regard. Their ESLint hooks plugin will give you warnings and errors when you don’t use a hook correctly. The Create-React-App build script will even fail to compile if there are any hooks errors.
Accidentally breaking a hooks rule is very easy, even for someone who tries not to. If you have a big hook, it may be hard to keep track of the dependencies, for example. Fixing these errors can be difficult when the only symptom is that your app doesn’t seem to work as expected at runtime.
A current workaround for this issue is to run ESLint on the JS output. However, this has its own shortcomings. For example, the plugin can only understand the output of hooks if it’s destructured when it’s declared, like this: const [count, setCount] = useState(0);. Since BuckleScript doesn’t output JS like this, the plugin won't understand that setCount is a hook dispatch, and it will throw an unncessary dependency warning if you use it inside another hook.
I imagine that adding this to ReasonReact won’t be trivial, but other React features are first-class citizens already. If it’s possible, I think it would be a great new feature.
- Dominant language
- Reason
- Stars
- 3.3k
- Forks
- 344
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from reasonml/reason-react
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
reasonml/reason-react#892 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 35/100
reasonml/reason-react#769 · 4 comments · 1 reaction ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 35/100
reasonml/reason-react#753 · 1 comment ·
-
docs
Difficulty 2/5 1-3 hours Newbie friendliness 35/100
reasonml/reason-react#717 · 1 comment ·
-
RFC
Difficulty 5/5 Over a week Newbie friendliness 25/100
reasonml/reason-react#698 · 2 reactions ·
All issues in reasonml/reason-react
Similar issues
-
clawsweeper:fix-shape-clear clawsweeper:queueable-fix clawsweeper:source-repro impact:ux-friction issue-rating: 🦞 diamond lobster no-stale P3
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
tvOS
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
bvaughn/react-resizable-panels#751 · 1 comment ·
-
www.wiwo.de OpenN: AdGuard Browser Extension P3: Medium T: Annoyance
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
AdguardTeam/AdguardFilters#242026 ·
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
Difficulty 1/5 Under an hour Newbie friendliness 92/100