Switching over from Js.t to bs.deriving has been simple for the most part, but I have hit a wall with declaring a empty object in record mode. I have tried Js.Obj.empty() and Js.Dict.empty(). I’ve duplicated the issue below, the problem I am having is in the initialState:
[@bs.deriving abstract]
type person = {
name: string,
age: int
};
let person_1 = person(~name="Joe", ~age=31);
type state = {
person
};
type action =
| FetchPerson(person);
let component = ReasonReact.reducerComponent("Person");
let make = _children => {
...component,
initialState: () => {
person: Js.Obj.empty()
},
reducer: (action, _state) =>
switch (action) {
| FetchPerson(data) => ReasonReact.Update({person: data})
},
render: self => {
<div>
<button onClick=((_) => self.send(FetchPerson(person_1)))>
(ReasonReact.string("load person info"))
</button>
<div>(ReasonReact.string(self.state.person |. name))</div>
</div>
}
};
If I switch over to using Js.t syntax, code compiles and works. Is empty object not supported yet in bs.deriving record mode?