0
I have a process component that should redirect me to another component, this other component will need to receive the process.ID, in order to render the records referring to the process.
I created such a method, but it was wrong, saying that this method does not exist in this context, as I could do it ?
I was recommended to see stateless and statefull, but I couldn’t apply it properly.
verProcesso(etapa) {
window.location.href(`../processos/etapas.jsx?${etapa}`);
}
How I rewrite the table
renderRows() {
return this.state.list.map(processo=> {
return (
<tr key={processo.id}>
<td>{processo.cliente}</td>
<td>{processo.etapa}</td>
<td>
<button className="btn btn-sm btn-info ml-2"
onClick={() => this.verProcesso(processo)}>
<i className="fa fa-eye"></i>
</button>
</td>
</tr>
)
})
}
my beautiful, good morning, have to apply "Arrow Function" to keep the context of "this" in reactjs
– Joan Marcos
const verProcesses = step => { window.location.href(
../processos/etapas.jsx?${etapa}
); }– Joan Marcos
I put it this way but it is accusing error in the syntax const verProcesso = step => { window.location.href(
../processos/etapas.jsx?${etapa}
); }– Andrews Gomes
It seems that it is missing, a Routes component for your React application and also not using window.location.href is not how it is done, even sending jsx address at the end does not exist this in
React
... you’re learning?– novic
I am learning I use routes, I have a file Routes.jsx that has a switch and a route for each link , but this serves only for the menu
– Andrews Gomes
@Virgilionovic I also tried to call a import { useHistory } from 'React-router-dom'; routeChange=()=> { Let path =
./home/home
; Let history = useHistory(); history.push(path); }– Andrews Gomes
@Virgilionovic there in my TD button I put onClick={() => this.routeChange()}> what I’m trying to do and very simple is u mbotão that redirects to another page passing the state , as if it were in php You can open a page by passing the parameters
– Andrews Gomes
There’s no such thing Andrews, in his current code of the expensive question ???
– novic
and that since I posted I’ve changed, I’m just trying to see some way
– Andrews Gomes
@Virgilionovic in all the examples I saw, the pages were the same never changed page
– Andrews Gomes
if you do not know what you are doing and so your doubt is already other
– novic
I know what I want but am problem to get the result I want, so I opened the question to get help on how to do it properly
– Andrews Gomes