Skip to content

Commit

Permalink
👌 #43 - PR feedback.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sven van de Scheur committed Jun 2, 2023
1 parent 23d7ea7 commit 427c11e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/containers/multiple/multiple.container.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export interface IMultipleProps extends IComponentProps {
*/
export const Multiple: React.FC<IMultipleProps> = props => {
const {component, form, path, value = [], setValue} = props; // FIXME: Awaits future pr.
const [keys, setKeys] = useState<number[]>(Array.from({length: 1}, (_, i) => i));
const [keys, setKeys] = useState<number[]>([0]);

/** Finds next key by increasing the max key with 1. */
const getKey = (): number => {
Expand All @@ -47,7 +47,7 @@ export const Multiple: React.FC<IMultipleProps> = props => {

/** Renders individual components utilizing <RenderComponent/>. */
const renderComponents = () =>
Array.from({length: keys.length}, (_, index) => {
keys.map((key, index) => {
// Clone and adjust component to fit nested needs.
const renderable: IRenderable = {
...structuredClone(component),
Expand All @@ -58,7 +58,7 @@ export const Multiple: React.FC<IMultipleProps> = props => {
};

return (
<tr key={keys[index]}>
<tr key={key}>
<td>
<RenderComponent component={renderable} form={form} path={path} value={value[index]} />
</td>
Expand All @@ -79,7 +79,7 @@ export const Multiple: React.FC<IMultipleProps> = props => {
<tfoot>
<tr>
<td>
<button type="button" onClick={() => add()}>
<button type="button" onClick={add}>
Add another
</button>
</td>
Expand Down

0 comments on commit 427c11e

Please sign in to comment.