0

https://codesandbox.io/s/react-16-s4dxs

import React, { useRef } from "react";
import { render } from "react-dom";
import Autosuggest from "react-autosuggest";

const styles = {
  fontFamily: "sans-serif",
  textAlign: "center"
};

const Wrapper = () => {
  const inputRef = useRef();
  return <App ref={inputRef} />;
};
const inputProps = {
  placeholder: "",
  value: "",
  "de-di-var": "",
  onChange: (event, { newValue }) => {
    console.log("change");
  },
  label: "",
  feedback: null,
  error: null
};
const App = React.forwardRef(({ error }, ref) => {
  return (
    <div style={styles}>
      <h4>Reference</h4>
      <Autosuggest
        inputProps={inputProps}
        ref={ref}
        suggestions=""
        undefined={false}
      />
    </div>
  );
});

render(<Wrapper />, document.getElementById("root"));

Ok, so I tried various things in order to add a valueless attribute such that I get something like: and not and I couldn't come with any solution. Obviously, I can add it manually to the input DOM element, but that's modifying a public library, which is not a good solution obviously. Is there a way to do this? I have tried to setting the value to undefined, null, "", and I tried other methods as well, which I won't detail here, but it seems that the library simply doesn't support it.

today
  • 5
  • 1
  • 6
  • Does this answer your question? [How to pass props without value to component](https://stackoverflow.com/questions/37828543/how-to-pass-props-without-value-to-component) – internet_user Jan 17 '20 at 16:45
  • No, because I need to populate an associative array called inputProps in order to add attributes to the input field. – today Jan 17 '20 at 17:44

0 Answers0