score:0
Accepted answer
using the react docs doc1 doc2 doc3
try this:
class radio extends react.component {
constructor(props) {
super(props);
this.state = {radio: 0};
this.onradiochanged = this.onradiochanged.bind(this);
}
onradiochanged(event) {
this.setstate({radio: parseint(event.target.value, 10)});
}
render() {
return (
<div>
<input type="radio"
value={0}
checked={this.state.radio === 0}
onchange={this.onradiochanged} />
option 1
<input type="radio"
value={1}
checked={this.state.radio === 1}
onchange={this.onradiochanged} />
option 2
{this.state.radio === 1? <button>hi!</button> : null}
</div>
);
}
}
react.render(
<radio/>,
document.body
);
Source: stackoverflow.com
Related Query
- React Append a button on radio button selection
- React radio button not update selection
- Radio Button Selection in React
- React Router navigate to another page on radio button selection
- Radio Button Selection in React Using Formik
- React Js - Clicking on child radio button hides the current and parent selection
- How to implement radio button in React Native
- Facing issue while adding radio button in react - input is a void element tag and must neither have `children` nor use `dangerouslySetInnerHTML`
- Append a React component in another on button click
- How to keep only one radio button selected with React
- Advanced positioning and sizing of a react radio button group on top of an SVG
- How to Show div when a Radio Button is Clicked in React
- React 16 Radio Button onChange not working
- How to use Radio Button in React Hook Form v7?
- React radio button onChange event does not bind on first change of radio button
- Radio button selection to change state
- How to get the selected value from a radio button group in React where there are multiple groups?
- Set radio button value in React
- How to render checked radio button in React
- Creating radio button in React using ref
- how to test radio button in react testing library(User can select other radio button)
- React - Can't Uncheck Radio Button
- how to count the number of times radio button is checked in react
- How do you toggle the checked value of a radio button in react using hooks?
- Setting a radio button to be checked as default, only when passing in a prop in React
- radio button in react
- React render, change radio button programmatically
- How to pass multiple values of selected radio button in React JS
- react testUtils simulate click on a radio button not triggering onchange
- Click on radio button and display the corresponding value inside the radio button as selected in react js material UI design
More Query from same tag
- Destructuring assignment vs array.map
- ESLint Parsing error: Unexpected token
- How to link to another page using react router?
- How can I use Jest to spy on a method call?
- Correctly update state for nested properties
- Get indian current time and date
- No overload matches this call on simple react app
- ReactJS: onClick handler not firing when placed on a child component
- Graphql mutation returning a Post 400 Error, not sure how to resolve
- React Hook Scroll to bottom of overflowing div on page load
- useState not re-rendering component if it is called inside callback function
- React-Paginate is not clickable
- tailwind css with css modules in next.js
- How to perform a single sign on between Django app and React JS app?
- Why React JS function not executing synchronously?
- How do I find the parameter type of a function implementing certain interface?
- tag:ReactJS Context.Provider value is not updated
- Empty state value for initial call in reactJs
- × Error: Alchemy URL protocol must be one of http, https, ws, or wss. Recieved: undefined React.js
- loop through api json data react js
- React+based on prop value i need to initiate a function which is already present in child component
- How do I use web sockets to generate a table from mySQL whenever there is a change in the database?
- Update value after render
- React 18: Hydration failed because the initial UI does not match what was rendered on the server
- Correct type of async action in redux with redux-thunk middleware
- How can I simply request axios.all using loop with array of strings in React?
- Returning a React Element within a Functional Component
- how to render content in the component that is loaded by useEffect- React
- How to add onclick event to a string rendered by dangerouslysetInnerHtml in reactjs?
- Hosting React App on Fire base having problem with routing