You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -37,12 +37,12 @@ root.render (Counter())
37
37
### ✨ Features
38
38
39
39
- Flexible **API design**: Combine the reliability of F# type safety with the flexibility to interop easily with native JavaScript.
40
-
- Discoverable **attributes** with no more functions, `Html` attributes or css properties globally available so they are easy to find.
40
+
- Discoverable **attributes** with no more functions, `Html` attributes or CSS properties globally available so they are easy to find.
41
41
- Proper **documentation**: each attribute and CSS property
42
42
- Full **React API** support: Feliz aims to support the React API for building components using hooks, context and more.
43
43
- Fully **Type-safe**: no more `Margin of obj` but instead utilizing a plethora of overloaded functions to account for the overloaded nature of `CSS` attributes, covering 90%+ of the CSS styles, values and properties.
44
44
-**Compatible** with [Femto](https://github.com/Zaid-Ajaj/Femto).
45
-
- Approximately **Zero** bundle size increase where everything function body is erased from the generated javascript unless you actually use said function.
45
+
- Approximately **Zero** bundle size increase where everything function body is erased from the generated JavaScript unless you actually use said function.
46
46
47
47
### 🚀 Quick Start
48
48
@@ -63,4 +63,4 @@ npm start
63
63
64
64
### 📚 Documentation
65
65
66
-
Feliz has extensive documentation at [https://zaid-ajaj.github.io/Feliz](https://zaid-ajaj.github.io/Feliz) with live examples along side code samples, check them out and if you have any question, let us know!
66
+
Feliz has extensive documentation at [https://zaid-ajaj.github.io/Feliz](https://zaid-ajaj.github.io/Feliz) with live examples alongside code samples, check them out and if you have any question, let us know!
Copy file name to clipboardExpand all lines: docs/docs/api-docs/feliz/react-component.mdx
+86-21Lines changed: 86 additions & 21 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -192,40 +192,105 @@ import ReactComponentImport from '../../feliz-docs/fableoutput/Examples/Feliz/Re
192
192
193
193
React `memo` components can be created using the `[<ReactMemoComponent>]` attribute. It works the same way as `[<ReactComponent>]`, but wraps the component in `React.memo` and ensures that it is defined as a `const` in the generated JavaScript code.
You can pass a custom equality function to the `[<ReactMemoComponent>]` attribute using the `areEqual` parameter. The value must be a JavaScript function expressed as a string. This function will be used to determine whether the component should re-render based on its props.
This behavior is similiar to the `[<Emit>]` attribute in Fable.
217
+
218
+
:::info
219
+
`areEqual` is implemented using the `[<StringSyntax("javascript")>]` attribute. This will provide syntax highlighting and basic validation in supported editors.
This works as f# equality does not check reference equality for arrays and sequences, but checks the content of them. Which is what is used by shallow comparison of React.memo.
264
+
:::
213
265
214
-
<TabItemvalue="JSX"label="JSX">
266
+
:::danger
267
+
The areEqual functions runs on the transformed js output, so you must assume, that your params are passed as a single object containing all props!
268
+
269
+
In the example above, if you want to compare the `fruits` prop, you need to access it as `prop1.fruits` and `prop2.fruits` in the `areEqualFn` function:
If you define your equality function as static member or inside a module, Fable might mangle the name of the function during transpilation. In this case, you need to provide the mangled name to the `areEqual` parameter. You can see this behavior int his [Fable Repl](https://fable.io/repl/#?code=PYBwpgdgBAYghgIwDZgHQGFgCcwChcC2wAJgK4pQCiAjqXEgJYAuAnjNALy5Q9QpNQ4OGnSTsoILKACMEqSABMULr1VyZy9Yvz8oAD00Q4BMMABmVWvWZsIqIWBH1xAehdQAzgAtg5YlAQwAC5LURt2AH0HJzEIfFZwUOtWdnQkOA8PWRVeDyY4JgYAYygTAkCsQWErWK1ZSVAlHLU6zQbtXF0WQ2NTCxjwiDSMrPtq0Vd3AZSh9MzpKPHnCCA&html=Q&css=Q).
Copy file name to clipboardExpand all lines: docs/docs/api-docs/guides/fable.mdx
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,6 +13,10 @@ import TabItem from '@theme/TabItem';
13
13
14
14
The following is a collection of short guides and tips for common pitfalls when using Fable for frontend development. Feel free to checkout the categories on the in-page table of contents in the sidebar and navigate to the topic you are interested in.
15
15
16
+
:::info[Fable]
17
+
More on Fable can be found in the ecosystem section [here](../../ecosystem/01_Tools/Fable.mdx).
18
+
:::
19
+
16
20
:::tip[Fable official docs]
17
21
18
22
Altough I might repeat some of the content here, I highly recommend you to check out the [official Fable JavaScript documentation](https://fable.io/docs/javascript/features.html). It contains a lot of useful information.
Copy file name to clipboardExpand all lines: docs/docs/api-docs/react/apis/memo.mdx
+47-4Lines changed: 47 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,15 +11,58 @@ import ReactRefAdmonition from '@site/src/components/ReactRefAdmonition';
11
11
12
12
`React.memo` lets you optimize components by memoizing their output. This prevents unnecessary rerenders when the props haven't changed, improving performance for pure components.
13
13
14
+
Without memoization, a component will rerender whenever its parent rerenders, even if its props remain the same. By wrapping a component with `React.memo`, React will skip rendering the component and reuse the last rendered output if the props are unchanged.
15
+
16
+
## ReactMemoComponentAttribute
17
+
18
+
The `[<ReactMemoComponent>]` attribute provides a convenient way to memoize functional components in Feliz. It does the transformation on transpile level so you don't have to wrap your component manually.
19
+
14
20
```fsharp
15
21
[<ReactMemoComponent>] // memoizes component to prevent rerender whenever parent rerenders
The `React.memo` function also accepts an optional second argument, `areEqual`, which is a custom comparison function for props. This function receives the previous and next props and should return `true` if they are equal (i.e., no rerender needed) or `false` if they are different (i.e., rerender needed).
60
+
61
+
This is useful as memo only does a shallow comparison of props by default. If your props are complex objects or arrays, you may need to provide a custom comparison function to accurately determine equality.
0 commit comments