Can't seem to get them to work.
# javascript
s
Can't seem to get them to work.
z
I had them working at one point in a project, but if I remember correctly, kotlin generates a wrapper function in the generated javascript that messes things up. I'll look and see if I can figure out what I did. I know I just mentioned using hooks and useReducer. Sorry about that.
s
No problem, this is a new feature in the wrapper, there is an example of using them directly.
Since the wrapper had a new implementation I thought I would give it a go. It was release per the first github link I posted about 5ish days ago.
Just no example of using them, which is understandable. It seems based on the troubleshooting they are a mite touchy, ref: https://github.com/facebook/react/issues/13991
z
I can't seem to find the code unfortunately... definitely frustrating. The hooks can only be called from a functional component, and I can't remember exactly how I did it, but I found a work around. I had a lot of frustration at the time because the kotlin compiler was wrapping my functional component with a wrapper function that immediately invoked my functional component. That was messing all sorts of stuff up. If you are able to figure out the work around, let me know.
s
Np, that's helpful, I will!
Copy code
val app = functionalComponent<RProps> {

    var (state, setState) = useState(0)

    div {

        div { +state.toString() }

        button {
            +"Click "
            attrs.onClickFunction = {
                console.log("Click")
                setState(state++)
            }
        }
    }
}
I needed
functionalComponent
. I was using RBuilder, which does not work. That works as expected.
z
Ah, that would be it