0
const StatelessComp = props => {

    const anotherFunction = () => (
       return <span><Button onClick={()=>props.incomingFunction}>Reset</Button></span>
    )

    return (
        <TableHeaderColumn
                    className="tableHeader"
                    dataFortmat={anotherFunction}
                >Restore</TableHeaderColumn>
};

why is it giving me error when i return something in anotherFunction. Id like to display a Restore button on a column.

Mayank Shukla
  • 100,735
  • 18
  • 158
  • 142

1 Answers1

1

It's an arrow function with a concise body. It must contain an expression, not any statements like return. You should write

const anotherFunction = () => (
  <span><Button onClick={()=>props.incomingFunction}>Reset</Button></span>
);

or

const anotherFunction = () => {
  return (
    <span><Button onClick={()=>props.incomingFunction}>Reset</Button></span>
  );
};
Bergi
  • 630,263
  • 148
  • 957
  • 1,375