Expand my Community achievements bar.

sightly+React

Avatar

Level 4

Hi,

Can anyone share a sample code which contains sightly and react js. A component which contains sightly and react js can anyone please share?

7 Replies

Avatar

Level 4

This post is a detailed step by step guide (steps sample code et al) for integrating AEM with React JS - https://sinnerschrader.github.io/aem-react/

Naveen

Avatar

Level 4

I just want to print 'Hello' in AEM page using react. I am adding the below script but it is not printing in the page. Can you please help?

<script>
React.render("hello", document.getElementById("app"));
</script>

Avatar

Level 4

The below code I have in sightly component, it is not printing "hello world" in the page. Can anyone please suggest??

<script>
var element = <h1>Hello, world</h1>;
ReactDOM.render(
  element,
  document.getElementById('root')
);
</script>
<div id="root"></div>
hello

Avatar

Level 4

yes I am getting console errors. Can you share a sample code which uses react js in AEM?

Avatar

Level 4

If I put the below code in /etc I get the error 'ReactDOM' is not defined. Do anyone know what to do?

ReactDOM.render(React.createElement('div', null, 'Hello from Kode'), document.getElementById('react-target'));

Avatar

Level 4

The above code works, but I am getting errors 'import' and '<' for react in AEM. How to use react in AEM??