1

I am mapping over data which returns an array of elements. In some cases tests.databases returns two database names and I would like to create a new line

2
  • can you show your array structure (unitTestData) and visual formation of your requirement please? Commented Oct 8, 2020 at 6:24
  • Just updated it in my question, thanks! Commented Oct 8, 2020 at 6:29

2 Answers 2

2

Map the array of database names to include a break element. Or you can wrap each name in its own div with style, whatever you need really.

{props.unitTestsData &&
  props.unitTestsData.map((test) => (
    <div key={test.id} className="Table UnitTestsGrid">
      <div>{test.id}</div>
      <div style={{ wordWrap: "break-word" }}>{test.unit_test_name}</div>
      <div style={{ wordWrap: "break-word" }}>
        {test.databases.map((el) => (
          <Fragment key={el}>
            {el}
            <br />
          </Fragment>
        ))}
      </div>
      <div>
        <Checkbox
          mainColor
          changeHandler={(e) => updateUnitTestSelection(e, test)}
          data={{}}
          id={test.id.toString()}
        />
      </div>
    </div>
  ))}
Sign up to request clarification or add additional context in comments.

1 Comment

You know me better than I know myself haha. Thanks!
0
<div style={{wordWrap: 'break-word'}}>{test.unit_test_name}</div>
<div style={{wordWrap: 'break-word'}}>{test.databases}</div>

Use span instead of div

2 Comments

haha all good, yeah it didn't work without the break word
use style={{display: 'block'}}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.