-
Notifications
You must be signed in to change notification settings - Fork 18
Open
Description
Not sure if this is a bug or not, but when passing items from one component to another one ends up with no items, despite them being available in e.g. the initialState-function.
let initialState = items => {
Console.log(("We've got some items here:", items));
items;
};
let%component childItem = (~items, ()) => {
let%hook (allItems, setItems) =
Hooks.reducer(~initialState=initialState(items), (value, _) => value);
// Works when using the effect-hook
/* let%hook () = */
/* Hooks.effect( */
/* OnMountAndIf((!=), items), */
/* () => { */
/* setItems(items); */
/* None; */
/* }, */
/* ); */
<View>
{allItems
|> List.map(item => <Text style=Style.[color(Colors.red)] text=item />)
|> React.listToElement}
</View>;
};
let%component container = () => {
let%hook (items, setItems) = React.Hooks.state([]);
let%hook () =
Hooks.effect(
OnMount,
() => {
setItems(_prev => ["One", "Two", "Three"]);
None;
},
);
<childItem items />;
};Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels