Skip to content

Instantly share code, notes, and snippets.

@danedavid
Created March 23, 2019 17:07
Show Gist options
  • Save danedavid/a4128ad06505d3841d110dfb0d0e9c4f to your computer and use it in GitHub Desktop.
Save danedavid/a4128ad06505d3841d110dfb0d0e9c4f to your computer and use it in GitHub Desktop.
import React, { useState } from 'react';
import { TextInputFormElement } from './TextInputFormElement';
import { NumberInputFormElement } from './NumberInputFormElement';
const data = ['a', 1, 'b', 2, 'c', 3, 'd', 4, 'e', 5];
const App = () => {
const [activeElement, setActiveElement] = useState('a');
return (
<div id='intersector' className='intersection-line'>
<div className="app-container">
{
data.map(item => (
typeof item === 'number'
? <NumberInputFormElement
active={activeElement === item}
key={item}
num={item}
setActiveElement={setActiveElement}
/>
: <TextInputFormElement
active={activeElement === item}
key={item}
char={item}
setActiveElement={setActiveElement}
/>
))
}
</div>
</div>
);
}
export default App;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment