I’m trying this Repo:
It’s worked to render, but I am confusing when I want to send data from react component to liveview.
README.md
said:
To push events back to the liveview the
pushEvent
,pushEventTo
andhandleEvent
functions from Phoenix LiveView are passed as props to the component.
const { pushEvent, pushEventTo, handleEvent } = this.props;
pushEvent(“button_click”);
pushEvent(“myevent”, {“var”: “value”});
pushEventTo(“#component-1”, “do_something”)
handleEvent(“some-event”, (payload) => console.log(payload))
But I don’t know how can I put these codes into my react-component example:
import React from "react"
function MyComponent(props) {
return <h1>Hello, {props.name}</h1>;
}
export {MyComponent};
Thanks a lot for Help!