score:2
Accepted answer
{input.length < 1 ? (
<Button style={{ display: "inline" }} onClick={AddInputField}>
click here to add company employees
</Button>
) : (
<Button style={{ display: "none" }}>
click here to add company employees
</Button>
)}
{input.length > 0 &&
input.map((value, i) => {
return (
<Row>
<Col>
<Form.Group>
<Form.Control
key={i}
value={value.empName}
name="empName"
type="text"
placeholder="Add Employee Name"
/>
</Form.Group>
</Col>
<Col>
<Button onClick={AddInputField}>Add</Button>
<Button onClick={() => RemoveInput(i)}>Remove</Button>
</Col>
</Row>
);
})}
Source: stackoverflow.com
Related Query
- Map() returning duplicate component
- React stateless component where map function is not returning
- I am getting an error in my map function returning React component
- Returning a component from a map function
- console.log inside a map in react component
- Leaflet React get map instance in functional component
- Using Google Map in React Component
- how to access vairables outside of map function in js and jsx in a React component
- React component returning cannot read property '__reactInternalInstance$ of null after trying to access array
- React - map array to child component
- Advantages of rendering a component vs a function returning JSX [React]
- Duplicate ReactJS import issue when using npm link to test component before publishing as npm package
- How to correctly replace type any when returning children or map of children if array
- Component not updating on Map (dictionary) state change using hooks
- How to test a component containing OpenLayers map using createReactApp
- Is there example there extend react-leaflet Map component to use leaflet.contextmenu?
- How to test if React component is returning null or its children using React Testing Library?
- React component function returning JSX causes error when used in render method of ES6 class React component
- Is it ok to convert Immutable.js Map to Object inside of react component
- React - Adding component in Map function not adding
- Material UI select multiple component using an object in the value property, adds duplicate entry
- How to show/hide component in parent component via a button in a child component when using a map of buttons?
- Returning null instead of a JSX when looping through arrays in react using map
- React: Map rendering component causing unnecessary re-renders, child key props not working?
- Bing Map component in React
- Render react Component from Map Object
- How to use ES6 map function in React stateless component
- ReactJS: setTimeout not working inside map to render component
- Functional component with hooks results in "cannot read property map of undefined"
- React Component returning "TypeError: undefined has no properties"
More Query from same tag
- React Error: "Cannot update during an existing state transition"
- Convert nested json object in reactJS?
- Only send values that have changed in formik onSubmit
- React js error in a simple function that takes an array and returns a random value
- Can't pass state with Link compoment. Why is state undefined?
- React- can't connect to server socket
- React - How to stay on the same page even if it was refreshed?
- OnClick not working when rendering React button on a custom dialog
- Using react-spring in a TypeScript component class throwing compilation problems
- How to add two functions passed as props to an onChange event in React and Material UI?
- Search Box implementation in React-leaflet v3.1.0 give an error "TypeError: Object(...) is not a function"
- How to create button like this UI?
- Filtering data causing an error called "Pasring error: Unexpected Token"
- Error in upgrading code from v5 to v6 in react router dom
- How to output components by some of their fields?
- How to trigger a function at regular intervals of time using hooks and when certain criteria is met I want to clear the time interval?
- Angular 2 V/S Angular js V/S React js v/s Typescript
- 'props' is not defined no-undef
- Setting state of nested array with React Hooks
- React - selenium tests
- Jest enzyme mock function not working with toHaveBeenCalled and mock.calls.length
- Use onChange in Material UI tabs handleChange function in React component
- React: Load Content from Server and Render to React
- Is there any way share state between
- Dynamic content with React js Modal
- React state updating multiple times on single setState call
- Why my ExpressJS is not able to get the static directory?
- Iterating through an array of objects in react to display a vertical scrolling item (Name & Logo)
- Receiving error when creating new app using create react app
- How can I load the data before the component in ReactJS?