score:0
you are returning jsx from the onclick handler, what you want to do is render some jsx based on current selected item.
to do so you can save a reference to the data (not the template)
example: onclick={() => setvisibletable(id)}
then somewhere else in the template you can decide to render a table based on the id.
{tables[id] &&
<table>
<tr>
<th>name</th>
<th>description</th>
</tr>
{tables[id].map((s) =>{
<tr key={s.name}>
<td>{s.name}</td>
<td>{s.description}</td>
</tr>
})}
</table>
}
Source: stackoverflow.com
Related Query
- React onClick function fires on render
- Render a table body in react using the map function
- Render React component with onClick and execute props function
- React - Table rows only render after unrelated function call
- Get my arrow function output and display it in a table format in render component in React
- React loop through object and render div with onClick function which takes argument
- React.js using onclick function to render a table
- React.js onClick function to to render a table
- Access React Context outside of render function
- onClick doesn't render new react component.
- onclick function is not working in react native application
- Render Content Dynamically from an array map function in React Native
- Does a render happen before function in React Hooks useEffect is called?
- React Context: TypeError: render is not a function
- Apply style "cursor: pointer" to all React components with onClick function
- Return DOM element in render function of React component
- React hooks: call component as function vs render as element
- Anchor tag isn't calling the onClick function in React
- React JS : history.push is not a function error and it isn't navigating to a different page onclick of swal
- React onClick function parameter turns into "Proxy" Object
- Using react hooks inside render prop function
- TypeError: Object(...) is not a function with React Table and moment.js
- React onClick function in map function
- How to get React Table Row Data Onclick
- React onClick event not firing when function is passed to child
- Passing current element to onClick function - React Jsx
- Trigger cell onClick instead of row onClick in React Table
- Call React Component Function from onclick in dangerouslySetInnerHTML
- React Table if Array is empty, no render
- React: How to add onChange functionality inside of Function component using React Hooks? Need onClick event from a checkbox to influence input state
More Query from same tag
- styled components server and client mismatch when importing from a yarn workspaces common package
- render function call immediately before fetching
- How to customize BooleanInput to add or remove items from a list?
- React css precedence
- Creating a control panel page in react
- redux update state value without changing initial state
- Sort an array of objects in React and render them
- I am having trouble retrieving my react project in the browser
- The items of dropdown menu overflow from the box
- Access state from render function
- React Hooks: state not updating when called inside Socket.io handler
- Exactly how are you supposed to debug JSX in React.js?
- Can't play video on iOS in Safari: NotAllowedError: The request is not allowed by the user agent or the platform in the current context
- Avoid having to specify a key for list of very simple elements
- React: unable to conditionally update state
- Deploying new contract to etherium network with web3.js
- React app with express server shows just blanc page
- React: How to change Table cell background depending on cell value in React table
- Redux Form + Material UI - Async validation running on change instead of blur
- Best practice for deleting related entities in normalized state in Redux
- which React component should i use with parameters?
- TypeError: Cannot read property 'state' of undefined. Updated React
- React useEffect with useState and setInterval
- Material UI v5 styles applied to class does'nt apply?
- State being emptied when adding objects with useState
- Material UI InputAdornment icon placement is outside the input area of TextField
- how to change icon size in googleMap ,react integration
- React-Query update cache after mutation performed
- Can't connect client (Javascript) to existing socket server
- How can I change the state submitting a form in React?