Comments (12)
Ok i'll do a PR changing the current signature
Move fast break things is one of the Facebook motto after all and they make React :)
from fable-react.
memo would take the JS function name.
For anonymous functions F# doesn't support naming them.
For normal ones Fable use name mangling so the name wouldnot be good.
So in the end I preferred forcing a name to be provided.
from fable-react.
One of the potential way to sidestep the problem would be to provide a more explicit name like memoBuilder
, createMemoBuilder
, ... something that echo the fact that the result should be saved & not used directly
from fable-react.
Ah ok I see.
I guess if we educate correctly the person and show your minimal example as a doc comment of memoBuilder
it should be fine.
Like that people can copy/paste the minimal example code and adapt it directly to their code.
from fable-react.
Ahah I guess that the comment explanation is ok as @alfonsogarciacaro and me answered the same thing at the same time :D
from fable-react.
let memo = memoBuilder
😁
from fable-react.
I am not sure to understand the benefit of simpleMemo
...
from fable-react.
I guess the benefit is you don't need to use ofElementType
:
ofElementType helloWorldComponent { Name = name } []
// vs
hello { Name = "World" }
But if it makes it easier to write cases where you lose the optimization I'd say we should keep only the API that leads user into the pit of success (you said that 😉). I'm a bit concerned than on one hand we're promoting the simplicity of Elmish and on the other users need to remember all the pitfalls of React. Savvy users can have a prelude with this kind of helpers for their projects 👍
from fable-react.
You start from :
let hello name =
span [] [str "Hello, "; str name]
let view model =
hello model.Name
Now you saw my talk and want to add components & get better perf :
type HelloProps = { Name: string }
let helloComponent = memo "Hello" <| fun { Name = name } ->
span [] [str "Hello, "; str name]
let hello p = ofComponentType helloComponent p []
let view model =
hello { Name = model.Name }
But what i'm proposing is to remove the temporary helloComponent
(That is always annoying to find a name for) :
type HelloProps = { Name: string }
let hello = simpleMemo "Hello" <| fun { Name = name } ->
span [] [str "Hello, "; str name]
let view model =
hello { Name = model.Name }
from fable-react.
Ah one of the other things to consider is that while it break memo optimizations it's pretty harmless... it ends up acting like ofFunction
so it's not much of a problem
Also the name memo (even "simple") is not something you might use accidentally so reading the function help might be something people would already do
from fable-react.
Hmm, memoBuilder
with explanation in the comment would work. But I'd be in favor to keep only one API (even if I already released a version with memo
) so users don't need to choose among many options and can just follow examples.
from fable-react.
Why does memoBuilder
need a string name but memo
does not?
from fable-react.
Related Issues (20)
- How to instantiate a custom React Component in Fable? HOT 2
- module.hot.addStatusHandler is not a function HOT 8
- React Server Components integration HOT 2
- Can't figure out how to wrap my view with a Higher Order Component HOT 4
- JsInterop helper for wrapping a higher order component HOT 2
- Can't reference React in Fable HOT 2
- Fable.ReactServer.cssProp very slow HOT 4
- Add Custom DU to DOMAttr HOT 1
- FunctionComponent.Lazy and SSR HOT 1
- Update samples to Fable 3
- ReactDOM.hydrate is no longer supported in React 18 HOT 17
- Can't update shared state passed with useContext? HOT 3
- Q: Use ReactElement import member for Storybook HOT 3
- Missing 'open' from Fable.React.Props? HOT 2
- Last Fable.React upgrade breaks my code HOT 7
- Publish source files from Fable.React.Types and Fable.ReactDom.Types to nuget HOT 5
- Fable.React version 8 depends on React.Dom gte 18 lt 19 according to femto
- Add Pointer Events HOT 3
- Why is useCallback not implemented? HOT 3
- How to obtain a component ref in a function component? HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fable-react.