I am making some tests in order to update a page on sharepoint on premise 2013. The goal is to use reactjs to modernize this page. However, when I try to use JSOM, especially to create an item, I encounter the following error:'SP' is not defined no-undef

I followed this tutorial to create a simple react app https://levelup.gitconnected.com/typescript-and-react-using-create-react-app-a-step-by-step-guide-to-setting-up-your-first-app-6deda70843a4?gi=7052bb815320

Installed this package "@types/sharepoint": "^2013.1.10", then added var itemCreateInfo = new SP.ListItemCreationInformation(); to my App.tsx

Do an npm start and then you see 'SP' is not defined no-undef. Build is impossible :/

Could anybody help me ?

With much thanks !! And excuse my English. This is my first post on this stackexchange


I found the solution

Just frame the code using SP like this

/*eslint-disable no-undef*/
let itemCreateInfo = new SP.ListItemCreationInformation();
/*eslint-enable no-undef*/


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.