How can I do to pass a list using React.js?

Hello I have this code :

import React, { Component } from 'react';
import Select from "./components/Select/Select";

class App extends Component {
  state = {
    testType : [
      {value : "test1", name : "Test1"},
      {value : "test2", name : "Test2"},
    ]
  }
    render() {
        return (
            <>
              <Select {...this.state.testType}/>
              <Select {...this.state.testType}/>
            </>
            );
    }
}
export default App;

This file is the first which allows to display some selects and below is the code which contains the Select.js :

import React from "react";
const selectoption = (props) => (
<select className="custom-select">
    <option value={props.value}>{props.name}</option>
</select>
);

export default selectoption;

But it does not work, I don't see the test1 and test2 in the select...

Could you help me please ?

Thank you very much !



Read more here: https://stackoverflow.com/questions/64415526/how-can-i-do-to-pass-a-list-using-react-js

Content Attribution

This content was originally published by Peter at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: