New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Question: Feliz.ElmishComponents vs Feliz.UseElmish #263
Comments
So |
Thanks a lot, Cody!!! So if I get i correctly, |
Yeah, we mostly still have |
Perfect! Thanks again! |
If it is "deprecated" it could be a good idea to mark it "Obselete" and redirect people to the recommended API. What do you think? |
Yes, we are just discussing with colleagues from F# team that we should do PR to documentation (maybe with link to this issue) |
Ok, I did it here - #264 |
Hi Roman, good question! The difference like Cody mentioned is that However, that is not the entire story, because
What do I mean by "re-initialization"? Well, imagine you are loading the user profile component based on URL changes as follows:
Basically, we want to re-initialize the type UserProfileProps = { UserId : int }
let UserProfile = React.functionComponent("UserProfile", fun (props: UserProfileProps) ->
let state, dispatch = React.useElmish(init props.UserId, update, [| props.UserId |])
Html.h1 (sprintf "UserProfile(UserId=%d)" props.UserId)
)
// later on application entry:
React.router [
router.onUrlChange (parseUrl >> UrlChanged >> dispatch)
router.children [
match state.CurrentUrl with
| [ "user-profile"; Route.Int userId ] -> UserProfile { UserId = userId }
| _ -> Html.h1 "Not found"
]
] Because we providing the the dependency array When neither the
This is typically used for components that don't need input from outside, like the entry component of the application. It can be a bit tricky to get used to the dependency array but they make a lot of sense, read more about it in Conditionally firing an effect from the hook docs. Final tip: |
Wow, typical Zaid's response. 馃槃 You should start teaching those things, man! I can finally understand. Thanks again! 鉂わ笍 |
Hello friend, it's been a while I bothered you with some retarded question, so it's time for another take. 馃槀
Can you please somehow describe what is the difference between
Feliz.ElmishComponents
andFeliz.UseElmish
? I see them both are React component having Elmish MVU parts. Are there any typical scenarios where you would choose one instead of another? I love easy of use ofFeliz.UseElmish
and just fear I am maybe missing something even cooler here. 馃槃The text was updated successfully, but these errors were encountered: