5.5.0
aaronlademann-wf
released this
10 Aug 15:24
·
543 commits
to master
since this release
This release of react includes...
New Features
-
π π π Support for function components, memo and hooks!!! π π π
Sooooo much work from so many amazing people made this possible, but to summarize:
- #221 Add support for function components
- #252 Add support for
memo
higher order component - Hooks, hooks, and more hooks!
It works like this...Define the component:
import 'package:react/react.dart' as react; final SomeWidget = react.registerFunctionComponent(_SomeWidget, displayName: 'SomeWidget'); _SomeWidget(Map props) { // You can use hooks in here, too! return react.div({}, [ // Some children... ]); }
Render the component (exact same consumer API as a class-based component):
import 'package:react/react_dom.dart' as react_dom; import 'some_widget.dart'; // Where your component is defined main() { final renderedWidget = SomeWidget({ // put some props here }, [ // put some children here! ]); react_dom.render(renderedWidget, querySelector('#idOfSomeNodeInTheDom')); }
Check out all the function component and hooks examples for more information!
Fixes / Updates